From b8cebe07fe31a38f0ea3ebbf42f6ef84b4f94122 Mon Sep 17 00:00:00 2001 From: guanhuan Date: Fri, 30 May 2025 15:06:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AA=E9=BD=90=E5=A5=97=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/sf_production_demand_plan.py | 37 ++++++++++++++++++- sf_demand_plan/views/demand_plan.xml | 5 ++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/sf_demand_plan/models/sf_production_demand_plan.py b/sf_demand_plan/models/sf_production_demand_plan.py index dcab21d4..44243fdb 100644 --- a/sf_demand_plan/models/sf_production_demand_plan.py +++ b/sf_demand_plan/models/sf_production_demand_plan.py @@ -97,9 +97,14 @@ class sf_production_plan(models.Model): actual_start_date = fields.Date('实际开工日期', compute='_compute_actual_start_date', store=True) actual_end_date = fields.Date('实际完工日期', compute='_compute_actual_end_date', store=True) print_count = fields.Char('打印次数', default='T0C0', readonly=True) - sequence = fields.Integer('序号') + hide_action_open_mrp_production = fields.Boolean( + string='显示待工艺确认按钮', + compute='_compute_hide_action_open_mrp_production', + default=False + ) + @api.depends('sale_order_id.state', 'sale_order_id.mrp_production_ids.schedule_state', 'sale_order_id.order_line', 'sale_order_id.mrp_production_ids.state') def _compute_status(self): @@ -329,3 +334,33 @@ class sf_production_plan(models.Model): 'res_id': self.sale_order_id.id, 'view_mode': 'form', } + + @api.depends('sale_order_id.mrp_production_ids.state') + def _compute_hide_action_open_mrp_production(self): + for record in self: + mrp_production_ids = record.sale_order_id.mrp_production_ids.filtered( + lambda p: p.state == 'technology_to_confirmed' and p.product_id.id == record.product_id.id + ) + record.hide_action_open_mrp_production = bool(mrp_production_ids) and record.supply_method in ( + 'automation', 'manual') + + def action_open_mrp_production(self): + mrp_production_ids = self.sale_order_id.mrp_production_ids.filtered( + lambda p: p.state == 'technology_to_confirmed' and p.product_id.id == self.product_id.id + ).ids + action = { + 'res_model': 'mrp.production', + 'type': 'ir.actions.act_window', + } + if len(mrp_production_ids) == 1: + action.update({ + 'view_mode': 'form', + 'res_id': mrp_production_ids[0], + }) + else: + action.update({ + 'name': _("制造订单列表"), + 'domain': [('id', 'in', mrp_production_ids)], + 'view_mode': 'tree,form', + }) + return action diff --git a/sf_demand_plan/views/demand_plan.xml b/sf_demand_plan/views/demand_plan.xml index 4e679bad..e3ca71ea 100644 --- a/sf_demand_plan/views/demand_plan.xml +++ b/sf_demand_plan/views/demand_plan.xml @@ -39,8 +39,11 @@ -