[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) <nim@odoo.com> closes odoo/odoo#32951 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user