[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.
This commit is contained in:
jem-odoo
2018-05-24 16:21:06 +02:00
parent 28179bc8cb
commit 919a1af936
+1 -1
View File
@@ -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)