[FIX] product_sale_price_from_pricelist: Fix JavaScript error in product form view

Fixed TypeError: value.toFixed is not a function when rendering monetary
fields in product form views. Added default=0.0 to list_price_theoritical
and last_purchase_price_received fields to prevent JavaScript from trying
to format False values as numbers.

Version bump: 18.0.2.1.0 -> 18.0.2.2.0
This commit is contained in:
snt 2026-02-14 17:22:15 +01:00
parent 2eaef82f3a
commit 1208990be3
3 changed files with 13 additions and 1 deletions

View file

@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [18.0.2.2.0] - 2026-02-14
### Fixed
- **Fixed JavaScript error in product form view**
- Error: `TypeError: value.toFixed is not a function`
- Added `default=0.0` to `list_price_theoritical` field
- Added `default=0.0` to `last_purchase_price_received` field
- This prevents JavaScript from trying to format `False` values as monetary fields
## [18.0.2.0.0] - 2026-02-12 ## [18.0.2.0.0] - 2026-02-12
### Changed ### Changed

View file

@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ # noqa: B018 { # noqa: B018
"name": "Product Sale Price from Pricelist", "name": "Product Sale Price from Pricelist",
"version": "18.0.2.1.0", "version": "18.0.2.2.0",
"category": "product", "category": "product",
"summary": "Set sale price from pricelist based on last purchase price", "summary": "Set sale price from pricelist based on last purchase price",
"author": "Odoo Community Association (OCA), Criptomart", "author": "Odoo Community Association (OCA), Criptomart",

View file

@ -19,12 +19,14 @@ class ProductProduct(models.Model):
list_price_theoritical = fields.Float( list_price_theoritical = fields.Float(
"Theoritical price", "Theoritical price",
company_dependent=True, company_dependent=True,
default=0.0,
) )
last_purchase_price_received = fields.Float( last_purchase_price_received = fields.Float(
string="Last purchase price", string="Last purchase price",
help="The last price at which the product was purchased. It is used as the base price field for calculating the product sale price.", help="The last price at which the product was purchased. It is used as the base price field for calculating the product sale price.",
digits="Product Price", digits="Product Price",
company_dependent=True, company_dependent=True,
default=0.0,
) )
last_purchase_price_compute_type = fields.Selection( last_purchase_price_compute_type = fields.Selection(
[ [