From 3d1d4575a648cb62555fd01d4956639d6db935b2 Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Mon, 8 Jul 2019 12:21:33 +0000 Subject: [PATCH] [REF] stock_account: allow receipt/deliveries at 0 in perpetual We still create a valuation layer for the traceability of what happened though. The rationale is that receiving free products is often requested by our customers. task-1985424 closes odoo/odoo#34683 Signed-off-by: Simon Lejeune (sle) --- addons/stock_account/models/stock_move.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/addons/stock_account/models/stock_move.py b/addons/stock_account/models/stock_move.py index 07c94f6ac27..0e92ab4b4c9 100644 --- a/addons/stock_account/models/stock_move.py +++ b/addons/stock_account/models/stock_move.py @@ -255,6 +255,8 @@ class StockMove(models.Model): for svl in stock_valuation_layers: if not svl.product_id.valuation == 'real_time': continue + if svl.currency_id.is_zero(svl.value): + continue svl.stock_move_id._account_entry_move(svl.quantity, svl.description, svl.id, svl.value) # For every in move, run the vacuum for the linked product. @@ -353,10 +355,6 @@ class StockMove(models.Model): # the standard_price of the product may be in another decimal precision, or not compatible with the coinage of # the company currency... so we need to use round() before creating the accounting entries. debit_value = self.company_id.currency_id.round(cost) - - # check that all data is correct - 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 valuation_partner_id = self._get_partner_id_for_valuation_lines()