排产的时候, 根据胚料的长宽高比对一下机床的最大加工尺寸.不符合就不要分配给这个加工中心(机床).

This commit is contained in:
jinling.yang
2023-02-17 15:01:43 +08:00
parent d5c2c8de86
commit d978f9d9b2
2 changed files with 20 additions and 14 deletions

View File

@@ -36,19 +36,21 @@ class ResMrpRoutingWorkcenter(models.Model):
elif len(workcenter_ids) >= 2:
# workcenter_ids_str = ','.join([str(s) for s in workcenter_ids])
if routing_type == 'CNC加工':
i = 0
# for item in workcenter_ids:
#
# machine_tool = self.env['sf.machine_tool'].search(
# [('x_axis', '>', product.length), ('y_axis', '>', product.width),
# ('z_axis', '>', product.height)])
# if machine_tool:
# for item in machine_tool:
# workcenter_ids = item.
workcenter = self.env['mrp.workcenter'].search([('id', 'in', workcenter_ids)])
workcenter_ids = []
for item in workcenter:
print(item.name)
if item.machine_tool_id:
machine_tool = self.env['sf.machine_tool'].search(
[('x_axis', '>', product.bom_ids.bom_line_ids.product_id.length), ('y_axis', '>', product.bom_ids.bom_line_ids.product_id.width),
('z_axis', '>', product.bom_ids.bom_line_ids.product_id.height), ('id', '=', item.machine_tool_id.id)])
if machine_tool:
workcenter_ids.append(item.id)
if len(workcenter_ids) == 1:
return workcenter_ids[0]
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')
workcenter_id = self.env.cr.dictfetchall()[0].get('workcenter_id')
return workcenter_id

View File

@@ -145,7 +145,9 @@ class ResMrpWorkOrder(models.Model):
'processing_panel': k,
'routing_type': route.routing_type,
'work_state': '' if not route.routing_type == '获取CNC加工程序' else '待发起',
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids,route.routing_type,production.product_id),
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids,
route.routing_type,
production.product_id),
'date_planned_start': False,
'date_planned_finished': False,
'duration_expected': 60,
@@ -355,7 +357,9 @@ class ResMrpWorkOrder(models.Model):
'processing_panel': k,
'routing_type': route.routing_type,
'work_state': '' if not route.routing_type == '获取CNC加工程序' else '待发起',
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids),
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids,
route.routing_type,
production.product_id),
'date_planned_start': False,
'date_planned_finished': False,
'duration_expected': 60,