Skip to content

Commit

Permalink
[MOD]add product image to bom overview
Browse files Browse the repository at this point in the history
  • Loading branch information
jayraj-omnia committed Jan 9, 2025
1 parent 9aec29f commit bbd8b0c
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 1 deletion.
2 changes: 2 additions & 0 deletions plm/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@
"web.assets_backend": [
"plm/static/src/css/component_kanban.css",
"plm/static/src/css/color_fields_tree.css",
"plm/static/src/js/mrp_bom_overview_line.js",
"plm/static/src/xml/mrp_bom_overview_table_inherit.xml",
],
'web.report_assets_common': [
"plm/static/src/scss/document_bom.scss",
Expand Down
3 changes: 2 additions & 1 deletion plm/report/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
from . import bom_document
from . import product_report_document
from . import bom_structure
from . import mrp_report_bom_structure



#import new_reports # To Delete when reports are working
#import new_reports # To Delete when reports are working
15 changes: 15 additions & 0 deletions plm/report/mrp_report_bom_structure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
from odoo import models


class ReportBomStructure(models.AbstractModel):
_inherit = 'report.mrp.report_bom_structure'

def _get_component_data(self, parent_bom, parent_product, warehouse, bom_line, line_quantity, level, index,
product_info, ignore_stock=False):

res = super()._get_component_data(parent_bom, parent_product, warehouse, bom_line, line_quantity, level, index,
product_info, ignore_stock)
res['image_component']= bom_line.product_id.image_1920

return res
14 changes: 14 additions & 0 deletions plm/static/src/js/mrp_bom_overview_line.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/** @odoo-module */

import { patch } from "@web/core/utils/patch";
import { BomOverviewLine } from "@mrp/components/bom_overview_line/mrp_bom_overview_line";

patch(BomOverviewLine.prototype, {
setup() {
super.setup();
this.image_data = false;
if(this.data && this.data.image_component){
this.image_data = 'data:image/png;base64, ' + this.data.image_component
}
}
});
18 changes: 18 additions & 0 deletions plm/static/src/xml/mrp_bom_overview_table_inherit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="plm.BomOverviewTable" t-inherit="mrp.BomOverviewTable" t-inherit-mode="extension">
<xpath expr="//th[@name='th_mrp_bom_h']" position="before">
<th name="th_mrp_bom_p_i">Image</th>
</xpath>
<xpath expr="//tfoot/tr/td" position="before">
<td/>
</xpath>
</t>
<t t-name="plm.BomOverviewLine" t-inherit="mrp.BomOverviewLine" t-inherit-mode="extension">
<xpath expr="//td" position="before">
<td name="td_mrp_bom">
<img t-if="image_data" t-att-src="this.image_data" width="50"/>
</td>
</xpath>
</t>
</templates>

0 comments on commit bbd8b0c

Please sign in to comment.