[FIX] mrp: correct unit cost in bom

Incorrect variable reference + calculation for unit BoM cost for
byproduct/product (to produce) within in BoM overview report. This
was leading to the displayed value having the cost_share being multipled
into the unit cost twice.

Steps to reproduce:

- create component with cost 100
- create BoM with 1 of this component + 1 byproduct with
  qty = 2 and cost_share = 50.00
- click on Overview

result before this commit:
Manufactured Product unit cost = 25.00
Byproduct unit cost = 12.50

actual result should be:
Manufactured Product unit cost = 50.00
Byproduct unit cost = 25.00

closes odoo/odoo#107410

X-original-commit: 2339bed170b5f670b1f5a6cebd533a9cee72d4db
Signed-off-by: Steve Van Essche <svs@odoo.com>
Signed-off-by: Tiffany Chang <tic@odoo.com>
This commit is contained in:
Tiffany Chang (tic)
2022-12-07 19:56:17 +01:00
parent 50ee5d7a09
commit a24d57daeb
2 changed files with 4 additions and 4 deletions
@@ -65,7 +65,7 @@
<td t-if="data['show_availabilities']"/>
<td t-if="data['show_lead_times']"/>
<td/>
<td class="text-end" t-esc="data['cost_share'] * data['bom_cost'] / data['quantity']" t-options='{"widget": "monetary", "display_currency": currency}'/>
<td class="text-end" t-esc="data['bom_cost'] / data['quantity']" t-options='{"widget": "monetary", "display_currency": currency}'/>
<td class="text-end" t-esc="data['prod_cost']/data['quantity']" t-options='{"widget": "monetary", "display_currency": currency}'/>
</tr>
<t t-if="data['show_costs'] and data['byproducts']" t-foreach="data['byproducts']" t-as="byproduct">
@@ -78,7 +78,7 @@
<td t-if="data['show_availabilities']"/>
<td t-if="data['show_lead_times']"/>
<td/>
<td class="text-end" t-esc="byproduct['cost_share'] * data['bom_cost'] / byproduct['quantity']" t-options='{"widget": "monetary", "display_currency": currency}'/>
<td class="text-end" t-esc="byproduct['bom_cost'] / byproduct['quantity']" t-options='{"widget": "monetary", "display_currency": currency}'/>
<td class="text-end" t-esc="byproduct['prod_cost'] / byproduct['quantity']" t-options='{"widget": "monetary", "display_currency": currency}'/>
</tr>
</t>
@@ -62,7 +62,7 @@
<td t-if="showAvailabilities"/>
<td t-if="showLeadTimes"/>
<td/>
<td class="text-end" t-esc="formatMonetary(data.cost_share * data.bom_cost / data.quantity)"/>
<td class="text-end" t-esc="formatMonetary(data.bom_cost / data.quantity)"/>
<td class="text-end" t-esc="formatMonetary(data.prod_cost / data.quantity)"/>
<td t-if="showAttachments"/>
</tr>
@@ -76,7 +76,7 @@
<td t-if="showAvailabilities"/>
<td t-if="showLeadTimes"/>
<td/>
<td class="text-end" t-esc="formatMonetary(byproduct.cost_share * data.bom_cost / byproduct.quantity)"/>
<td class="text-end" t-esc="formatMonetary(byproduct.bom_cost / byproduct.quantity)"/>
<td class="text-end" t-esc="formatMonetary(byproduct.prod_cost / byproduct.quantity)"/>
<td t-if="showAttachments"/>
</tr>