Skip to content

Commit 5421bea

Browse files
Yenthe666mart-e
authored andcommitted
[Fix] stock_account: detect if there is no price change
The warning tells the user that there is no difference between the standard price and new price, while the if condition does the exact opposite. Closes odoo#13797 Fixes odoo#13785
1 parent 2054337 commit 5421bea

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

addons/stock_account/models/product.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from odoo import api, fields, models, tools, _
55
from odoo.exceptions import UserError
6+
from odoo.tools import float_is_zero
67

78

89
class ProductTemplate(models.Model):
@@ -105,7 +106,7 @@ def do_change_standard_price(self, new_price, account_id):
105106
for location in locations:
106107
for product in self.with_context(location=location.id, compute_child=False):
107108
diff = product.standard_price - new_price
108-
if diff:
109+
if float_is_zero(diff, precision_rounding=product.currency_id.rounding):
109110
raise UserError(_("No difference between standard price and new price!"))
110111
if not product_accounts[product.id].get('stock_valuation', False):
111112
raise UserError(_('You don\'t have any stock valuation account defined on your product category. You must define one before processing this operation.'))

0 commit comments

Comments
 (0)