I’ve created an addon that inherits from mrp.bom and added a barcode field which relates to product_tmpl.barcode and it displays numbers. I can add that field just fine to the tree and form views for mrp.bom, but when it comes to displaying it in the mrp.report_mrp_bom or report_mrp_bom_pdf_line view, I fail. I can add in the column name, just not the values for each component line in the BoM.
I’ve noticed a .py file in mrp/report/ named something like mrp_report_bom_structure.py that has a class with loads of different methods inside to get things like pdf line data, bom data, component data, etc. Do I need to somehow inherit from that class and methods? I’ve not found any documentation for Odoo on inheriting methods.
If anyone is familiar with any of this, all I need is to be able to add a single field into the report that shows the barcode number for the BoM itself and all of its components and sub-components.
~Model~
class BoMs(models.Model):
_inherit = "mrp.bom"
barcode = fields.Char(
related="product_tmpl_id.barcode", string="Barcode", store=True
)
~View~
<odoo>
<data>
<!-- BoM Overview Report -->
<template id="report_mrp_bom_inherit" inherit_id="mrp.report_mrp_bom">
<!-- Adding Barcode to the header -->
<xpath expr="//table/thead/tr/th[1]" position="after">
<th>Barcode</th>
</xpath>
</template>
<!-- BoM lines -->
<template id="report_mrp_bom_pdf_line_inherit" inherit_id="mrp.report_mrp_bom_pdf_line">
<xpath expr="//tr/td[1]" position="after">
<td t-esc="l['barcode'] or ''"/>
</xpath>
</template>
</data>
</odoo>