From bc27113cf50c0ced19d1e3668bf5c3af15b1e526 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 9 Apr 2019 12:14:49 +0000 Subject: [PATCH] [FIX] stock_account: price unit is zero - Set a product P to average valuation, real time - Create a PO for 1 unit @ 100, validate the picking - Create a PO for 1 unit @ 0 (e.g. you receive a free product) You cannot validate the picking because of the message 'The cost of P is currently equal to 0...' This error message is historical, to prevent users from an incorrect configuration. Since we still want to prevent misconfiguration, but support the mentioned use case, we introduce an `ir._config_parameter` for people who 'know what they are doing'. opw-1962249 closes odoo/odoo#32550 Signed-off-by: Nicolas Martinelli (nim) closes odoo/odoo#32951 Signed-off-by: Nicolas Martinelli (nim) --- addons/stock_account/models/stock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock_account/models/stock.py b/addons/stock_account/models/stock.py index 156ee0dedab..23276976ff5 100644 --- a/addons/stock_account/models/stock.py +++ b/addons/stock_account/models/stock.py @@ -563,7 +563,7 @@ class StockMove(models.Model): debit_value = self.company_id.currency_id.round(valuation_amount) # check that all data is correct - if self.company_id.currency_id.is_zero(debit_value): + if self.company_id.currency_id.is_zero(debit_value) and not self.env['ir.config_parameter'].sudo().get_param('stock_account.allow_zero_cost'): raise UserError(_("The cost of %s is currently equal to 0. Change the cost or the configuration of your product to avoid an incorrect valuation.") % (self.product_id.display_name,)) credit_value = debit_value