From fa87b0d6fff52f42c70ac80bce32f4133c825a66 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 18 May 2017 11:46:38 +0200 Subject: [PATCH] [FIX] purchase: _anglo_saxon_purchase_move_lines Let's consider a stockable product P with a product category PC with costing method = real price, valuation = perpetual, stock valuation account = SVA and price diff account = PDA. The cost defined for P in product.template is equal to 1$. Steps -Create a PO for P with a price unit = 5$ -Confirm PO and generate the invoice -Update the qty for P in the invoice and validate it(price unit is still 5$) Bug: In the general ledger: a move with a debit of 1$ is created for SVA and a debit of 4$ is created for PDA which is wrong. The expected result is: just a move of 5$ created for SVA and nothing for PDA because the difference between the purchase price and the invoiced price is 0. This commit fixes this problem. NB: in real price and average price, the considered cost must be the purchase price and not the cost defined in the product template. opw:740879 --- addons/purchase/models/account_invoice.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/purchase/models/account_invoice.py b/addons/purchase/models/account_invoice.py index 9c1cf48312c..873921b322f 100644 --- a/addons/purchase/models/account_invoice.py +++ b/addons/purchase/models/account_invoice.py @@ -144,6 +144,7 @@ class AccountInvoice(models.Model): valuation_price_unit = i_line.product_id.uom_id._compute_price(i_line.product_id.standard_price, i_line.uom_id) if i_line.product_id.cost_method != 'standard' and i_line.purchase_line_id: #for average/fifo/lifo costing method, fetch real cost price from incomming moves + valuation_price_unit = i_line.purchase_line_id.product_uom._compute_price(i_line.purchase_line_id.price_unit, i_line.uom_id) stock_move_obj = self.env['stock.move'] valuation_stock_move = stock_move_obj.search([('purchase_line_id', '=', i_line.purchase_line_id.id), ('state', '=', 'done')]) if valuation_stock_move: