From a2b2efed7d27b55af542a7cddf510bcb3ee545db Mon Sep 17 00:00:00 2001 From: guanhuan Date: Tue, 8 Jul 2025 15:46:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=A4=E8=B4=A7=E6=95=B0=E9=87=8F=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_demand_plan/models/sf_demand_plan.py | 2 +- sf_demand_plan/models/sf_production_demand_plan.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/sf_demand_plan/models/sf_demand_plan.py b/sf_demand_plan/models/sf_demand_plan.py index 15e82844..9c55aadd 100644 --- a/sf_demand_plan/models/sf_demand_plan.py +++ b/sf_demand_plan/models/sf_demand_plan.py @@ -62,7 +62,7 @@ class SfDemandPlan(models.Model): model_machining_precision = fields.Selection(related='product_id.model_machining_precision', string='精度') inventory_quantity_auto_apply = fields.Float( string="成品库存", - compute='_compute_inventory_quantity_auto_apply', store=True + compute='_compute_inventory_quantity_auto_apply' ) priority = fields.Selection([ diff --git a/sf_demand_plan/models/sf_production_demand_plan.py b/sf_demand_plan/models/sf_production_demand_plan.py index 0f8fe1e8..f0bbd708 100644 --- a/sf_demand_plan/models/sf_production_demand_plan.py +++ b/sf_demand_plan/models/sf_production_demand_plan.py @@ -77,7 +77,7 @@ class SfProductionDemandPlan(models.Model): qty_delivered = fields.Float( "交货数量", related='sale_order_line_id.qty_delivered') qty_to_deliver = fields.Float( - "待交货数量", related='sale_order_line_id.qty_to_deliver') + "待交货数量", compute='_compute_qty_to_deliver', store=True) model_long = fields.Char('尺寸(mm)', compute='_compute_model_long') blank_type = fields.Selection([('圆料', '圆料'), ('方料', '方料')], string='坯料分类', related='product_id.blank_type') @@ -212,6 +212,15 @@ class SfProductionDemandPlan(models.Model): else: line.supply_method = line.new_supply_method + @api.depends('sale_order_line_id.qty_to_deliver') + def _compute_qty_to_deliver(self): + for line in self: + if float_compare(line.sale_order_line_id.qty_to_deliver, 0, + precision_rounding=line.product_id.uom_id.rounding) == -1: + line.qty_to_deliver = 0 + else: + line.qty_to_deliver = line.sale_order_line_id.qty_to_deliver + @api.depends('supply_method') def _compute_route_ids(self): for pdp in self: