1.优化根据同一个产品,生成的制造订单绑定同一个编程单需求

This commit is contained in:
jinling.yang
2024-05-07 17:33:23 +08:00
parent 7cbe1cb35d
commit fda43deeea
6 changed files with 26 additions and 13 deletions

View File

@@ -56,8 +56,9 @@ class MrpProduction(models.Model):
glb_file = fields.Binary("glb模型文件")
production_line_id = fields.Many2one('sf.production.line', string='生产线')
plan_start_processing_time = fields.Datetime('计划开始加工时间')
production_line_state = fields.Selection([('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')],
string='/下产线', default='待上产线')
production_line_state = fields.Selection(
[('待上产线', '待上产线'), ('已上产线', '上产线'), ('已下产线', '已下产线')],
string='上/下产线', default='待上产线')
# 工序状态
# Todo 研究下用法
process_state = fields.Selection([
@@ -114,7 +115,7 @@ class MrpProduction(models.Model):
# production.state = 'pending_processing'
production.state = 'pending_cam'
if production.state == 'progress' and production.schedule_state == '已排' and production.process_state == '待加工':
# if production.state == 'pending_cam' and production.process_state == '待加工':
# if production.state == 'pending_cam' and production.process_state == '待加工':
production.state = 'pending_processing'
elif production.state == 'progress' and production.process_state == '待解除装夹':
production.state = 'pending_era_cam'
@@ -262,10 +263,14 @@ class MrpProduction(models.Model):
# 其他规则限制: 默认只分配给工作中心状态为非故障的工作中心;
def _create_workorder3(self):
programming_no = None
product_id_new = None
for production in self:
if not production.bom_id or not production.product_id:
continue
workorders_values = []
if product_id_new is None:
product_id_new = production.product_id
product_qty = production.product_uom_id._compute_quantity(production.product_qty,
production.bom_id.product_uom_id)
@@ -290,7 +295,14 @@ class MrpProduction(models.Model):
'state': 'pending',
}]
if production.product_id.categ_id.type == '成品':
production.fetchCNC()
if programming_no is None:
production.fetchCNC()
programming_no = production.programming_no
else:
if production.product_id == product_id_new:
if not production.programming_no:
production.write({'programming_no': programming_no, 'programming_state': '编程中'})
# 根据加工面板的面数及对应的工序模板生成工单
i = 0
processing_panel_len = len(production.product_id.model_processing_panel.split(','))
@@ -524,8 +536,8 @@ class MrpProduction(models.Model):
# work.button_finish()
# 创建工单并进行排序
def _create_workorder(self):
self._create_workorder3()
def _create_workorder(self, programming_no_new):
self._create_workorder3(programming_no_new)
self._reset_work_order_sequence()
return True