Skip to content
Snippets Groups Projects
Commit 1bdca992 authored by Jignesh Rathod's avatar Jignesh Rathod Committed by Josse Colpaert
Browse files

[IMP] MRP : Improve bom cost report.

Use HTML version instead
parent 104ef28a
No related branches found
No related tags found
No related merge requests found
......@@ -19,18 +19,17 @@ class MrpBomCost(models.AbstractModel):
for value in product.attribute_value_ids:
attributes += [(value.attribute_id.name, value.name)]
result, result2 = bom.explode(product, 1)
product_line = {'name': product.name, 'lines': [], 'total': 0.0,
product_line = {'bom': bom, 'name': product.name, 'lines': [], 'total': 0.0,
'currency': self.env.user.company_id.currency_id,
'product_uom_qty': bom.product_qty,
'product_uom': bom.product_uom_id,
'attributes': attributes}
total = 0.0
for bom_line, line_data in result2:
line_product = line_data['product']
price_uom = self.env['product.uom']._compute_qty(line_product.uom_id.id, line_product.standard_price, bom_line.product_uom_id.id)
price_uom = self.env['product.uom']._compute_qty(bom_line.product_id.uom_id.id, bom_line.product_id.standard_price, bom_line.product_uom_id.id)
line = {
'product_id': line_product,
'product_uom_qty': line_data['qty'],
'product_id': bom_line.product_id,
'product_uom_qty': line_data['qty'], #line_data needed for phantom bom explosion
'product_uom': bom_line.product_uom_id,
'price_unit': price_uom,
'total_price': price_uom * line_data['qty'],
......
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="mrp_bom_cost">
<div class="o_form_view">
<div class="page o_form_sheet_bg">
<div class="o_form_sheet">
<t t-foreach="lines" t-as="line">
<t t-call="report.html_container">
<t t-foreach="lines" t-as="line">
<t t-call="report.internal_layout">
<div class="page">
<t t-set="currency" t-value="line['currency']"/>
<table class="table table-condensed">
<thead>
......@@ -24,7 +24,7 @@
</th>
</tr>
<tr>
<th colspan="2">Raw Materials</th>
<th colspan="3">Raw Materials</th>
<th class="col-sm-2 text-right">Quantity</th>
<th class="col-sm-2 text-right">Unit Cost</th>
<th class="col-sm-2 text-right">Total Cost</th>
......@@ -32,24 +32,30 @@
</thead>
<tbody>
<tr t-foreach="line['lines']" t-as="bom_line">
<td colspan="2">
<span t-esc="bom_line['product_id'].name"/>
<td colspan="3">
<span t-att-res-id="bom_line['product_id'].id" res-model="product.product" view-type="form" t-esc="bom_line['product_id'].name"/>
</td>
<td class="text-right">
<span t-esc="bom_line['product_uom_qty']"/> <span t-esc="bom_line['product_uom'].name" groups="product.group_uom"/>
</td>
<td class="text-right"><span t-esc="bom_line['price_unit']" t-esc-options='{"widget": "monetary", "display_currency": "currency"}'/></td>
<td class="text-right"><span t-esc="bom_line['total_price']" t-esc-options='{"widget": "monetary", "display_currency": "currency"}'/></td>
<td class="text-right">
<span t-esc="bom_line['price_unit']" t-options='{"widget": "monetary", "display_currency": currency}'/>
</td>
<td class="text-right">
<span t-esc="bom_line['total_price']" t-options='{"widget": "monetary", "display_currency": currency}'/>
</td>
</tr>
<tr>
<th colspan="4" class="text-right">Total Cost of Raw Materials</th>
<th class="text-right"><t t-esc="line['total']" t-esc-options='{"widget": "monetary", "display_currency": "currency"}'/></th>
<th colspan="5" class="text-right">Total Cost of Raw Materials</th>
<th class="text-right">
<span t-esc="line['total']" t-options='{"widget": "monetary", "display_currency": currency}'/>
</th>
</tr>
</tbody>
</table>
</t>
</div>
</div>
</div>
</div>
</t>
</t>
</t>
</template>
</odoo>
......@@ -24,7 +24,7 @@
model="mrp.bom"
name="mrp_bom_cost"
file="mrp_bom_cost"
report_type="qweb-pdf"
report_type="qweb-html"
/>
</data>
</openerp>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment