From 5421beafb1519d99dd2f4bc8f1abb1fea79258ab Mon Sep 17 00:00:00 2001 From: "Yenthe V.G" Date: Thu, 13 Oct 2016 14:39:33 +0200 Subject: [PATCH] [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 #13797 Fixes #13785 --- addons/stock_account/models/product.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/stock_account/models/product.py b/addons/stock_account/models/product.py index 5ab32db789a..a81b0260253 100644 --- a/addons/stock_account/models/product.py +++ b/addons/stock_account/models/product.py @@ -3,6 +3,7 @@ from odoo import api, fields, models, tools, _ from odoo.exceptions import UserError +from odoo.tools import float_is_zero class ProductTemplate(models.Model): @@ -105,7 +106,7 @@ class ProductProduct(models.Model): for location in locations: for product in self.with_context(location=location.id, compute_child=False): diff = product.standard_price - new_price - if diff: + if float_is_zero(diff, precision_rounding=product.currency_id.rounding): raise UserError(_("No difference between standard price and new price!")) if not product_accounts[product.id].get('stock_valuation', False): raise UserError(_('You don\'t have any stock valuation account defined on your product category. You must define one before processing this operation.'))