upd 16 [app_mrp_production_zchart]

This commit is contained in:
Chill
2024-12-19 15:08:40 +08:00
parent 3839df53d5
commit b3f4e30a33
2 changed files with 13 additions and 12 deletions

View File

@@ -23,7 +23,7 @@
{
'name': 'MRP Production zChart Hierarchy, 多级BoM生产单多层级执行结构图,适用于多级BoM的生产工单,一棵树全览关联生产',
'version': '16.24.12.12',
'version': '16.24.12.19',
'author': 'odooai.cn',
'category': 'Base',
'website': 'https://www.odooai.cn',
@@ -31,9 +31,9 @@
'sequence': 2,
'summary': """
Manufacture Order multi level. For Multi level MO MRP Production Order from multi bom. MRP Hierarchy. MO hierarchy
Chart Hierarchy Widget. Hierarchy Chart, Hierarchy Tree for multi level Parent Children relation tree.
Chart Hierarchy Widget. Hierarchy Chart, Hierarchy Tree for multi level Parent Children relation tree.
""",
'description': """
'description': """
MRP Hierarchy chart, MO Hierarchy chart, mrp multi level.
Need extra paid apps app_web_widget_ztree
This module extend to show a Hierarchy chart.

View File

@@ -18,24 +18,25 @@ class MrpProduction(models.Model):
parent_id = fields.Many2one('mrp.production', 'Parent Manufacturing', index=True, ondelete='cascade',
help="The parent manufacturing orders that generate this order. Follow the rule of multi level bom.")
child_ids = fields.One2many('mrp.production', 'parent_id', string='Sub Manufacturing')
child_all_count = fields.Integer('Indirect Surbordinates Count', store=False,
child_all_count = fields.Integer('Indirect Surbordinates Count', store=False, recursive=True,
compute='_compute_child_all_count')
image_128 = fields.Image(related='product_id.image_128', readonly=True)
product_name = fields.Char(related='product_id.name', readonly=True)
parent_path = fields.Char(index=True)
parent_path = fields.Char(index=True, unaccent=False)
@api.depends('child_ids.child_all_count')
def _compute_child_all_count(self):
for rec in self:
rec.child_all_count = len(rec.child_ids) + sum(child.child_all_count for child in rec.child_ids)
@api.model
def create(self, values):
@api.model_create_multi
def create(self, vals_list):
# 配置层级关系
if 'origin' in values and values['origin']:
mo = self.env['mrp.production'].search([('name', '=', values['origin'])], limit=1, order='id desc')
if len(mo) == 1:
values['parent_id'] = mo[0].id
res = super(MrpProduction, self).create(values)
for vals in vals_list:
if 'origin' in vals and vals['origin']:
mo = self.env['mrp.production'].search([('name', '=', vals['origin'])], limit=1, order='id desc')
if len(mo) == 1:
vals['parent_id'] = mo[0].id
res = super(MrpProduction, self).create(vals_list)
return res