From c4621d36a3f17dbc72f50bebfd9f4a238d8002d7 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Mon, 1 Jul 2024 16:56:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AE=A2=E5=8D=95=E7=8A=B6?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 52 ++++--------------- .../views/mrp_production_addional_change.xml | 2 +- 2 files changed, 12 insertions(+), 42 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 3a49c2fa..7464886d 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -30,13 +30,10 @@ class MrpProduction(models.Model): # ('completed', '已完工') # ]) state = fields.Selection([ - ('draft', '待排程'), - ('confirmed', '待加工'), + ('draft', '草稿'), + ('confirmed', '待排程'), + ('pending_cam', '待加工'), ('progress', '加工中'), - # ('pending_cam', '待装夹'), - # ('pending_processing', '待加工'), - # ('pending_era_cam', '待解除装夹'), - ('completed', '已完工'), ('to_close', 'To Close'), ('done', 'Done'), ('cancel', 'Cancelled')], string='State', @@ -82,7 +79,7 @@ class MrpProduction(models.Model): @api.depends( 'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state', - 'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state', 'process_state') + 'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state') def _compute_state(self): for production in self: if not production.state or not production.product_uom_id: @@ -103,27 +100,6 @@ 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') 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): - production.state = 'progress' - elif any(not float_is_zero(move.quantity_done, - 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 == 'to_close' and production.schedule_state == '未排': - production.state = 'draft' - elif production.state == 'to_close' and production.schedule_state == '已排': - 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, @@ -131,20 +107,14 @@ class MrpProduction(models.Model): production.state = 'progress' elif any(not float_is_zero(move.quantity_done, precision_rounding=move.product_uom.rounding or move.product_id.uom_id.rounding) - for move in production.move_raw_ids): + for move in production.move_raw_ids if move.product_id): production.state = 'progress' - # if production.state == 'progress' and production.schedule_state == '已排' and production.process_state == '待装夹': - # # 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 == '待加工': - # production.state = 'pending_processing' - # elif production.state == 'progress' and production.process_state == '待解除装夹': - # production.state = 'pending_era_cam' - # elif production.state == 'progress' and production.process_state == '已完工': - # production.state = 'completed' - # elif production.state == 'progress' and production.work_order_state == '已完成': - # production.state = 'completed' + + # # 新添加的状态逻辑 + if production.state == 'to_close' and production.schedule_state == '未排': + production.state = 'confirmed' + elif production.state == 'to_close' and production.schedule_state == '已排': + production.state = 'pending_cam' def action_check(self): """ diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml index efab7e2d..b65dfb2f 100644 --- a/sf_manufacturing/views/mrp_production_addional_change.xml +++ b/sf_manufacturing/views/mrp_production_addional_change.xml @@ -65,7 +65,7 @@ - draft,confirmed,progress,completed,done + confirmed,pending_cam,progress,done