From 919a1af93601f3873b78c755575cf0486da24e4e Mon Sep 17 00:00:00 2001 From: jem-odoo Date: Thu, 24 May 2018 14:10:50 +0200 Subject: [PATCH] [FIX] purchase: correct product cost in reporting product.product inheritS from product.template, and they both define the 'standard_price' field, but implement it differently; - product: the field is a company dependent one (so non stored) - template: the field is a computed one based on tis variants For the first case, since the field is not stored in database, when doing SQL query, we have to get the value from the table ir_property. That is what purchase report does, but instead of searching on resource 'product.product', it does it on 'product.template'. There are obviously no entries in ir_property table for 'standard_price' field on product template. As consequence, the "product value" (cost) is always null in purchase reporting. This commit fixes that by modifying SQL query to get the good value from ir_property table. --- addons/purchase/report/purchase_report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/purchase/report/purchase_report.py b/addons/purchase/report/purchase_report.py index a1a6cb4e3b2..b5ef4110c31 100644 --- a/addons/purchase/report/purchase_report.py +++ b/addons/purchase/report/purchase_report.py @@ -82,7 +82,7 @@ class purchase_report(osv.osv): join res_partner partner on s.partner_id = partner.id left join product_product p on (l.product_id=p.id) left join product_template t on (p.product_tmpl_id=t.id) - LEFT JOIN ir_property ip ON (ip.name='standard_price' AND ip.res_id=CONCAT('product.template,',t.id) AND ip.company_id=s.company_id) + LEFT JOIN ir_property ip ON (ip.name='standard_price' AND ip.res_id=CONCAT('product.product,',p.id) AND ip.company_id=s.company_id) left join product_uom u on (u.id=l.product_uom) left join product_uom u2 on (u2.id=t.uom_id) left join stock_picking_type spt on (spt.id=s.picking_type_id)