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: