新增
This commit is contained in:
4
mrp_plm/report/__init__.py
Normal file
4
mrp_plm/report/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import mrp_report_bom_structure
|
||||
46
mrp_plm/report/mrp_report_bom_structure.py
Normal file
46
mrp_plm/report/mrp_report_bom_structure.py
Normal file
@@ -0,0 +1,46 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import models
|
||||
|
||||
|
||||
class ReportBomStructure(models.AbstractModel):
|
||||
_inherit = 'report.mrp.report_bom_structure'
|
||||
|
||||
def _get_pdf_doc(self, bom_id, data, quantity, product_variant_id=None):
|
||||
doc = super()._get_pdf_doc(bom_id, data, quantity, product_variant_id)
|
||||
doc['show_ecos'] = True if data and data.get('show_ecos') == 'true' and self.env.user.user_has_groups('mrp_plm.group_plm_user') else False
|
||||
return doc
|
||||
|
||||
def _get_report_data(self, bom_id, searchQty=0, searchVariant=False):
|
||||
res = super()._get_report_data(bom_id, searchQty, searchVariant)
|
||||
res['is_eco_applied'] = self.env.user.user_has_groups('mrp_plm.group_plm_user')
|
||||
return res
|
||||
|
||||
def _get_bom_data(self, bom, warehouse, product=False, line_qty=False, bom_line=False, level=0, parent_bom=False, index=0, product_info=False, ignore_stock=False):
|
||||
res = super()._get_bom_data(bom, warehouse, product, line_qty, bom_line, level, parent_bom, index, product_info, ignore_stock)
|
||||
if self.env.user.user_has_groups('mrp_plm.group_plm_user'):
|
||||
res['version'] = res['bom'] and res['bom'].version or ''
|
||||
product_tmpl_id = (res['product'] and res['product'].product_tmpl_id.id) or (res['bom'] and res['product'].product_tmpl_id.id)
|
||||
res['ecos'] = self.env['mrp.eco'].search_count([('product_tmpl_id', '=', product_tmpl_id), ('state', '!=', 'done')]) or ''
|
||||
return res
|
||||
|
||||
def _get_component_data(self, bom, warehouse, bom_line, line_quantity, level, index, product_info, ignore_stock=False):
|
||||
res = super()._get_component_data(bom, warehouse, bom_line, line_quantity, level, index, product_info, ignore_stock)
|
||||
if self.env.user.user_has_groups('mrp_plm.group_plm_user'):
|
||||
res['version'] = False
|
||||
res['ecos'] = self.env['mrp.eco'].search_count([('product_tmpl_id', '=', res['product'].product_tmpl_id.id), ('state', '!=', 'done')]) or ''
|
||||
return res
|
||||
|
||||
def _get_bom_array_lines(self, data, level, unfolded_ids, unfolded, parent_unfolded):
|
||||
lines = super()._get_bom_array_lines(data, level, unfolded_ids, unfolded, parent_unfolded)
|
||||
if not self.env.user.user_has_groups('mrp_plm.group_plm_user'):
|
||||
return lines
|
||||
for component in data.get('components', []):
|
||||
if not component['bom_id']:
|
||||
continue
|
||||
bom_line = next(filter(lambda l: l.get('bom_id', None) == component['bom_id'], lines))
|
||||
if bom_line:
|
||||
bom_line['version'] = component['version']
|
||||
bom_line['ecos'] = component['ecos']
|
||||
|
||||
return lines
|
||||
38
mrp_plm/report/mrp_report_bom_structure.xml
Normal file
38
mrp_plm/report/mrp_report_bom_structure.xml
Normal file
@@ -0,0 +1,38 @@
|
||||
<odoo>
|
||||
<template id="report_mrp_bom_inherit_mrp_plm" inherit_id="mrp.report_mrp_bom">
|
||||
<xpath expr="//th[@name='th_mrp_bom_h']" position="after">
|
||||
<th t-if="data['show_ecos']">BoM Version</th>
|
||||
<th t-if="data['show_ecos']">ECOs</th>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//td[@name='td_mrp_bom']" position="after">
|
||||
<td t-if="data['show_ecos']">
|
||||
<span t-esc="data['version']"/>
|
||||
</td>
|
||||
<td t-if="data['show_ecos']">
|
||||
<span t-esc="data['ecos']"/>
|
||||
</td>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//td[@name='td_mrp_bom_f']" position="after">
|
||||
<td t-if="data['show_ecos']"/>
|
||||
<td t-if="data['show_ecos']"/>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//td[@name='td_mrp_bom_byproducts_f']" position="after">
|
||||
<td t-if="data['show_ecos']"/>
|
||||
<td t-if="data['show_ecos']"/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="report_mrp_bom_pdf_line_inherit_mrp_plm" inherit_id="mrp.report_mrp_bom_pdf_line">
|
||||
<xpath expr="//td[@name='td_mrp_code']" position="after">
|
||||
<td t-if="data['show_ecos']">
|
||||
<span t-if="l.get('version')" t-esc="l['version']"/>
|
||||
</td>
|
||||
<td t-if="data['show_ecos']">
|
||||
<span t-if="l.get('ecos')" t-esc="l['ecos']"/>
|
||||
</td>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user