From 0d512e2e43ea966542917cf49e1f04f39353b01d Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Tue, 22 Oct 2024 13:55:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=B6=E9=80=A0=E8=AE=A2=E5=8D=95=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=AE=A2=E5=8D=95=E4=BA=A4=E6=9C=9F=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 25 +++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 55076fc6..573bb73f 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -37,12 +37,25 @@ class MrpProduction(models.Model): @api.depends('procurement_group_id.mrp_production_ids.move_dest_ids.group_id.sale_id') def _compute_deadline_of_delivery(self): for production in self: - sale_order_id = production.procurement_group_id.mrp_production_ids.move_dest_ids.group_id.sale_id - if not sale_order_id: - continue - sale_id = self.env['sale.order'].sudo().browse(int(sale_order_id)) - if sale_id: - production.deadline_of_delivery = sale_id.deadline_of_delivery + # 确保 procurement_group_id 和相关字段存在 + if production.procurement_group_id: + # 获取相关的 sale_id + sale_order_id = production.procurement_group_id.mrp_production_ids.mapped( + 'move_dest_ids.group_id.sale_id') + + # 确保 sale_order_id 是有效的 ID 列表 + if sale_order_id: + # 获取 sale.order 记录 + sale_id = self.env['sale.order'].sudo().browse(sale_order_id.ids) # 使用 mapped 返回的 ID 列表 + + # 处理 sale_id + if sale_id: + # 假设我们只需要第一个 sale_id + production.deadline_of_delivery = sale_id[0].deadline_of_delivery if sale_id else False + else: + production.deadline_of_delivery = False + else: + production.deadline_of_delivery = False @api.depends('workorder_ids.tool_state_remark') def _compute_tool_state_remark(self):