From 9416d1c1a0db762cbe247232d8be883b9d5aa5f7 Mon Sep 17 00:00:00 2001 From: "lixiaobin@jikimo.com" Date: Wed, 16 Jul 2025 11:20:26 +0800 Subject: [PATCH] BUG_7276_lxb_commit --- sf_demand_plan/models/sf_demand_plan.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sf_demand_plan/models/sf_demand_plan.py b/sf_demand_plan/models/sf_demand_plan.py index bfdfc022..9728e464 100644 --- a/sf_demand_plan/models/sf_demand_plan.py +++ b/sf_demand_plan/models/sf_demand_plan.py @@ -222,10 +222,15 @@ class SfDemandPlan(models.Model): line_ids = self.line_ids.filtered(lambda p: p.status == '30') sum_product_uom_qty = sum(line_ids.mapped('plan_uom_qty')) customer_location_id = self.env['ir.model.data']._xmlid_to_res_id('stock.stock_location_customers') - if not self.overdelivery_allowed and line_ids.filtered(lambda p: p.location_id.id == customer_location_id): - if float_compare(sum_product_uom_qty, self.product_uom_qty, - precision_rounding=self.product_id.uom_id.rounding) == 1: - raise ValidationError(f"已禁止向合作伙伴/客户超量发货,请更换“补货原因”或将“可超量发货”设置为“是”。") + check_overdelivery_allowed = False + for line in line_ids: + if line.location_id.id == customer_location_id: + if not self.overdelivery_allowed: + if float_compare(sum_product_uom_qty, self.product_uom_qty, + precision_rounding=line.product_id.uom_id.rounding) == 1: + check_overdelivery_allowed = True + if check_overdelivery_allowed: + raise ValidationError(f"已禁止向合作伙伴/客户超量发货,请更换“补货原因”或将“可超量发货”设置为“是”。") elif float_compare(sum_product_uom_qty, self.product_uom_qty, precision_rounding=self.product_id.uom_id.rounding) == 1: return {