From 5a071188ccec7e799a41f6f335e85de99a77a2ac Mon Sep 17 00:00:00 2001 From: guanhuan Date: Thu, 12 Jun 2025 10:53:46 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9C=80=E6=B1=82=E8=AE=A1=E5=88=92=E5=AF=B9?= =?UTF-8?q?=E5=BA=94=E4=BA=A7=E5=93=81=E7=9A=84=E8=B0=83=E6=8B=A8=E5=8D=95?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=8D=E6=AD=A3=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_demand_plan/__manifest__.py | 2 +- .../models/sf_production_demand_plan.py | 16 ++++++++++------ sf_demand_plan/views/demand_plan.xml | 3 +++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/sf_demand_plan/__manifest__.py b/sf_demand_plan/__manifest__.py index 932685e0..0f4f2311 100644 --- a/sf_demand_plan/__manifest__.py +++ b/sf_demand_plan/__manifest__.py @@ -10,7 +10,7 @@ """, 'category': 'sf', 'website': 'https://www.sf.jikimo.com', - 'depends': ['sf_plan', 'jikimo_printing'], + 'depends': ['sf_plan'], 'data': [ 'security/ir.model.access.csv', 'views/demand_plan.xml', diff --git a/sf_demand_plan/models/sf_production_demand_plan.py b/sf_demand_plan/models/sf_production_demand_plan.py index 3b0a19b6..df1e2990 100644 --- a/sf_demand_plan/models/sf_production_demand_plan.py +++ b/sf_demand_plan/models/sf_production_demand_plan.py @@ -91,7 +91,7 @@ class SfProductionDemandPlan(models.Model): route_id = fields.Many2one('stock.route', string='路线', related='sale_order_line_id.route_id', store=True) contract_date = fields.Date('合同日期', related='sale_order_id.contract_date') date_order = fields.Datetime('下单日期', related='sale_order_id.date_order') - contract_code = fields.Char('合同号', related='sale_order_id.contract_code') + contract_code = fields.Char('合同号', related='sale_order_id.contract_code', store=True) plan_remark = fields.Text("计划备注") material_check = fields.Selection([ ('0', "未齐套"), @@ -160,10 +160,12 @@ class SfProductionDemandPlan(models.Model): if pending_productions: record.status = '50' # 待下达生产 # 检查所有制造订单的排程单状态 - if record.sale_order_id.mrp_production_ids and all( - order.product_id == record.product_id and order.schedule_state != '未排' for order in - record.sale_order_id.mrp_production_ids): - record.status = '60' # 已下达 + if record.sale_order_id.mrp_production_ids: + product_productions = record.sale_order_id.mrp_production_ids.filtered( + lambda p: p.product_id.id == record.product_id.id + ) + if product_productions and all(order.schedule_state != '未排' for order in product_productions): + record.status = '60' # 已下达 if sale_order_state == 'cancel' or not record.sale_order_line_id: record.status = '100' # 取消 @@ -458,7 +460,9 @@ class SfProductionDemandPlan(models.Model): record.hide_action_stock_picking = False record.hide_action_outsourcing_stock_picking = False if record.supply_method in ('automation', 'manual'): - manufacturing_orders = record.sale_order_id.mrp_production_ids + manufacturing_orders = record.sale_order_id.mrp_production_ids.filtered( + lambda p: p.product_id.id == record.product_id.id + ) record.hide_action_stock_picking = bool(manufacturing_orders.mapped('picking_ids').filtered( lambda p: p.state == 'assigned')) elif record.supply_method in ('purchase', 'outsourcing'): diff --git a/sf_demand_plan/views/demand_plan.xml b/sf_demand_plan/views/demand_plan.xml index 251fae8d..f78e5cf6 100644 --- a/sf_demand_plan/views/demand_plan.xml +++ b/sf_demand_plan/views/demand_plan.xml @@ -85,6 +85,7 @@ + @@ -97,6 +98,8 @@ context="{'group_by': 'deadline_of_delivery'}"/> +