Skip to content
Snippets Groups Projects
Commit c43b338b authored by Pierre Masereel's avatar Pierre Masereel
Browse files

[FIX] stock_account: do_change_standard_price traceback

* bad creation of a dictionnary with the dictionary comprehension syntax.
  correction of the syntax.
* unnecessery use of decimal precision function because the wizard is already
  in the good decimal precision. Remove the decimal precision call and lib.
* traceback when the valuation account was not defined on product category.
  raise exception when no valuation account, to explain the user why he can't
  change the price.
parent d4724220
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,6 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models, tools, _
from odoo.addons import decimal_precision as dp
from odoo.exceptions import UserError
......@@ -101,14 +100,15 @@ class ProductProduct(models.Model):
locations = self.env['stock.location'].search([('usage', '=', 'internal'), ('company_id', '=', self.env.user.company_id.id)])
product_accounts = {(product.id, product.product_tmpl_id.get_product_accounts()) for product in self}
price_precision = dp.get_precision('Product Price')
product_accounts = {product.id: product.product_tmpl_id.get_product_accounts() for product in self}
for location in locations:
for product in self.with_context(location=location.id, compute_child=False):
diff = product.standard_price - new_price
if tools.float_is_zero(diff, precision_digits=price_precision):
if diff:
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.'))
qty_available = product.qty_available
if qty_available:
# Accounting Entries
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment