修改匹配加工中心

This commit is contained in:
jinling.yang
2022-11-04 16:08:43 +08:00
parent 14d0d32ab6
commit 65a7d74430
3 changed files with 40 additions and 19 deletions

View File

@@ -27,17 +27,17 @@ class ResMrpRoutingWorkcenter(models.Model):
# 如果只配置了一个工作中心,则默认采用该工作中心;
# 如果有多个工作中心,
# 则根据该工作中心的工单个数进行分配(优先分配给工单个数最少的);
# def get_workcenter(self, workcenter_ids):
# print(workcenter_ids[0].id)
# if workcenter_ids:
# if len(workcenter_ids) == 1:
# return workcenter_ids[0].id
# elif len(workcenter_ids) >= 2:
# workcenter_id = self.env['mrp.workorder'].search(
# [('workcenter_ids.id', 'in', True)],
# limit=1,
# group_by =
# )
def get_workcenter(self, workcenter_ids):
if workcenter_ids:
if len(workcenter_ids) == 1:
return workcenter_ids[0]
elif len(workcenter_ids) >= 2:
# workcenter_ids_str = ','.join([str(s) for s in workcenter_ids])
self.env.cr.execute("""
SELECT workcenter_id FROM mrp_workorder where workcenter_id
in %s group by workcenter_id
order by count(*),workcenter_id asc limit 1 """, [tuple(workcenter_ids)])
return self.env.cr.dictfetchall()[0].get('workcenter_id')
class ModelTypeRoutingSort(models.Model):

View File

@@ -17,18 +17,40 @@
</record>
#-----------------工单-------------------
<record model="ir.ui.view" id="view_mrp_production_workorder_tree_inherit_sf">
<field name="name">mrp.production.workorder.tree.inherit.sf</field>
<record model="ir.ui.view" id="view_mrp_production_workorder_form_inherit_sf">
<field name="name">mrp.production.workorder.form.inherit.sf</field>
<field name="model">mrp.workorder</field>
<field name="inherit_id" ref="mrp.mrp_production_workorder_tree_view"/>
<field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>
<field name="arch" type="xml">
<field name="name" position="after">
<field name="processing_panel"/>
<field name="production_id" position="after">
<field name="processing_panel" readonly="1"/>
</field>
</field>
</record>
#-----------------制造订单的工单-------------------
<!-- <record model="ir.ui.view" id="view_mrp_production_workorder_tree_inherit_sf">-->
<!-- <field name="name">mrp.production.workorder.tree.inherit.sf</field>-->
<!-- <field name="model">mrp.workorder</field>-->
<!-- <field name="inherit_id" ref="mrp.mrp_production_workorder_tree_view"/>-->
<!-- <field name="arch" type="xml">-->
<!-- <field name="workcenter_id" position="replace">-->
<!-- <filter name="workcenter_ids" string="工作中心" />-->
<!-- </field>-->
<!-- </field>-->
<!-- </record>-->
<!-- <record model="ir.ui.view" id="view_mrp_production_workorder_filter_inherit_sf">-->
<!-- <field name="name">mrp.production.workorder.filter.inherit.sf</field>-->
<!-- <field name="model">mrp.workorder</field>-->
<!-- <field name="inherit_id" ref="mrp.view_mrp_production_workorder_form_view_filter"/>-->
<!-- <field name="arch" type="xml">-->
<!-- <xpath expr="//filter[@name='work_center']" position="replace">-->
<!-- <filter name="work_center" string="工作中心" context="{'group_by': 'workcenter_ids'}"/>-->
<!-- </xpath>-->
<!-- </field>-->
<!-- </record>-->
#-----------------制造订单里的工单-------------------
<record model="ir.ui.view" id="view_mrp_production_workorder_tree_editable_inherit_sf">
<field name="name">mrp.production.workorder.tree.editable.inherit.sf</field>
<field name="model">mrp.workorder</field>