[IMP] mrp: Show the bom reference on BoM report.

Each line that contains a manufacturable product displays its
BoM (clickable with an html report). _get_bom_reference function
is used in order to add information about BoM in report (e.g plm
module add its version).

Task id: 1857701
This commit is contained in:
Arnold Moyaux
2018-08-09 11:13:00 +02:00
parent 88bf279c46
commit bb05e833f9
2 changed files with 21 additions and 0 deletions
@@ -54,6 +54,9 @@ class ReportBomStructure(models.AbstractModel):
}
return self.env.ref('mrp.report_mrp_operation_line').render({'data': values})
def _get_bom_reference(self, bom):
return bom.display_name
@api.model
def _get_report_data(self, bom_id, searchQty=0, searchVariant=False):
lines = {}
@@ -98,6 +101,7 @@ class ReportBomStructure(models.AbstractModel):
'bom_prod_name': product.display_name,
'currency': self.env.user.company_id.currency_id,
'product': product,
'code': bom and self._get_bom_reference(bom) or '',
'price': product.uom_id._compute_price(product.standard_price, bom.product_uom_id) * bom_quantity,
'total': sum([op['total'] for op in operations]),
'level': level or 0,
@@ -128,6 +132,7 @@ class ReportBomStructure(models.AbstractModel):
components.append({
'prod_id': line.product_id.id,
'prod_name': line.product_id.display_name,
'code': line.child_bom_id and self._get_bom_reference(line.child_bom_id) or '',
'prod_qty': line_quantity,
'prod_uom': line.product_uom_id.name,
'prod_cost': price,
@@ -192,6 +197,7 @@ class ReportBomStructure(models.AbstractModel):
'prod_cost': bom_line['prod_cost'],
'bom_cost': bom_line['total'],
'level': bom_line['level'],
'code': bom_line['code']
})
if bom_line['child_bom'] and (unfolded or bom_line['child_bom'] in child_bom_ids):
line = self.env['mrp.bom.line'].browse(bom_line['line_id'])
@@ -24,6 +24,7 @@
<thead>
<tr>
<th>Product</th>
<th>BoM</th>
<th>Quantity</th>
<th groups="uom.group_uom">Unit of Measure</th>
<th t-if="data['report_structure'] != 'bom_cost'" class="o_mrp_prod_cost" title="This is the cost defined on the product.">Product Cost</th>
@@ -36,6 +37,9 @@
<td>
<span><a t-if="data['report_type'] == 'html'" t-att-data-res-id="data['product'].id" t-att-data-model="'product.product'" class="o_mrp_bom_action"><t t-esc="data['bom_prod_name']"/></a><t t-else="" t-esc="data['bom_prod_name']"/></span>
</td>
<td>
<span><a t-if="data['report_type'] == 'html'" t-att-data-res-id="data['bom'].id" t-att-data-model="'mrp.bom'" class="o_mrp_bom_action"><t t-esc="data['code']"/></a><t t-else="" t-esc="data['code']"/></span>
</td>
<td><span><t t-esc="data['bom_qty']" t-options='{"widget": "float", "decimal_precision": "Product Unit of Measure"}'/></span></td>
<td groups="uom.group_uom"><span><t t-esc="data['bom'].product_uom_id.name"/></span></td>
<td t-if="data['report_structure'] != 'bom_cost'" class="o_mrp_prod_cost">
@@ -57,6 +61,7 @@
</tbody>
<tfoot>
<tr>
<td></td>
<td></td>
<td><span><strong>Unit Cost</strong></span></td>
<td groups="uom.group_uom"></td>
@@ -96,6 +101,11 @@
<span class="fa fa-dropbox" title="This is a BoM of type Kit!" role="img" aria-label="This is a BoM of type Kit!"/>
</t>
</td>
<td>
<span>
<a t-att-data-res-id="l['child_bom']" t-att-data-model="'mrp.bom'" class="o_mrp_bom_action"><t t-esc="l['code']"/></a>
</span>
</td>
<td><span><t t-esc="l['prod_qty']" t-options='{"widget": "float", "decimal_precision": "Product Unit of Measure"}'/></span></td>
<td groups="uom.group_uom"><span><t t-esc="l['prod_uom']"/></span></td>
<td class="o_mrp_prod_cost">
@@ -121,6 +131,7 @@
<span class="o_mrp_bom_unfoldable fa fa-fw fa-caret-right" t-att-data-function="'get_operations'" role="img" aria-label="Unfold" title="Unfold"/>
Operations
</td>
<td/>
<td>
<span t-esc="data['operations_time']" t-options='{"widget": "float_time"}'/>
</td>
@@ -144,6 +155,7 @@
<span t-att-style="space_td"/>
<a t-att-data-res-id="op['operation'].id" t-att-data-model="'mrp.routing.workcenter'" class="o_mrp_bom_action"><t t-esc="op['name']"/></a>
</td>
<td/>
<td>
<span t-esc="op['duration_expected']" t-options='{"widget": "float_time"}'/>
</td>
@@ -173,6 +185,9 @@
<span t-att-style="space_td"/>
<span><t t-esc="l['name']"/></span>
</td>
<td>
<span t-if="l.get('code')" t-esc="l['code']" />
</td>
<td>
<span>
<t t-if="l['type'] == 'operation'" t-esc="l['quantity']" t-options='{"widget": "float_time"}'/>