1,修复制造订单状态:第一张装夹工单未就绪是,状态需为:待加工;所有工单完成后,状态需为:完成;2.修复多个产品确认制造订单未生产多个编程单问题3.优化工单页面:去掉非必要的字段

This commit is contained in:
jinling.yang
2024-06-30 11:45:52 +08:00
parent 5668722109
commit 4a648fbd7b
6 changed files with 20 additions and 36 deletions

View File

@@ -102,7 +102,7 @@ class MrpProduction(models.Model):
elif not production.workorder_ids and float_compare(production.qty_producing, production.product_qty,
precision_rounding=production.product_uom_id.rounding) >= 0:
production.state = 'to_close'
elif any(wo_state in ('progress', 'done') for wo_state in production.workorder_ids.mapped('state')):
elif any(wo_state in ('progress') for wo_state in production.workorder_ids.mapped('state')):
production.state = 'progress'
elif production.product_uom_id and not float_is_zero(production.qty_producing,
precision_rounding=production.product_uom_id.rounding):
@@ -119,6 +119,10 @@ class MrpProduction(models.Model):
production.state = 'confirmed'
# if production.schedule_state == '已完成':
# production.state = 'completed'
elif production.workorder_ids and production.workorder_ids[0].state == 'ready':
production.state = 'confirmed'
elif all(wo_state in ('done') for wo_state in production.workorder_ids.mapped('state')):
production.state = 'done'
elif any(wo_state in ('progress', 'done') for wo_state in production.workorder_ids.mapped('state')):
production.state = 'progress'
elif production.product_uom_id and not float_is_zero(production.qty_producing,
@@ -128,9 +132,6 @@ class MrpProduction(models.Model):
precision_rounding=move.product_uom.rounding or move.product_id.uom_id.rounding)
for move in production.move_raw_ids):
production.state = 'progress'
# if production.state == 'progress' and production.schedule_state == '已排' and production.process_state == '待装夹':
# # production.state = 'pending_processing'
# production.state = 'pending_cam'

View File

@@ -136,11 +136,6 @@ class ResMrpWorkOrder(models.Model):
supplier_id = fields.Many2one('res.partner', string='外协供应商')
equipment_id = fields.Many2one('maintenance.equipment', string='加工设备', tracking=True)
is_ok = fields.Boolean(string='是否合格')
# 加工人
processing_user_id = fields.Many2one('res.users', string='加工人')
# 检测人
inspection_user_id = fields.Many2one('res.users', string='检测人')
# 保存名称
save_name = fields.Char(string='检测文件保存名称', compute='_compute_save_name')
# 获取数据状态
@@ -234,16 +229,6 @@ class ResMrpWorkOrder(models.Model):
ids = [t[0] for t in self.env.cr.fetchall()]
return [('id', 'in', ids)]
@api.onchange('is_ok')
def _onchange_inspection_user_id(self):
"""
检测is_ok(是否合格)被修改的话就将当前用户赋值给inspection_user_id
"""
if not self.inspection_user_id:
self.inspection_user_id = self.env.user.id
else:
self.inspection_user_id = False
@api.onchange('functional_fixture_id')
def _onchange_functional_fixture_id(self):
if self.functional_fixture_id:
@@ -1036,7 +1021,7 @@ class ResMrpWorkOrder(models.Model):
if raw_move:
raw_move.write({'state': 'done'})
record.production_id.button_mark_done1()
record.production_id.state = 'done'
# record.production_id.state = 'done'
# 将FTP的检测报告文件下载到临时目录
def download_reportfile_tmp(self, workorder, reportpath):

View File

@@ -261,13 +261,14 @@ class StockRule(models.Model):
'product_id': production.product_id.id,
'state': 'draft',
})
grouped_product_ids = {k: list(g) for k, g in groupby(productions, key=lambda x: x.product_id.id)}
all_production = productions
grouped_product_ids = {k: list(g) for k, g in groupby(all_production, key=lambda x: x.product_id.id)}
# 初始化一个字典来存储每个product_id对应的生产订单名称列表
product_id_to_production_names = {}
# 对于每个product_id获取其所有生产订单的名称
for product_id, productions in grouped_product_ids.items():
for product_id, all_production in grouped_product_ids.items():
# 为同一个product_id创建一个生产订单名称列表
product_id_to_production_names[product_id] = [production.name for production in productions]
product_id_to_production_names[product_id] = [production.name for production in all_production]
for production_item in productions:
if production_item.product_id.id in product_id_to_production_names:
# # 同一个产品多个制造订单对应一个编程单和模型库