diff --git a/sf_demand_plan/models/sf_production_demand_plan.py b/sf_demand_plan/models/sf_production_demand_plan.py index 28c733c8..9a736ee5 100644 --- a/sf_demand_plan/models/sf_production_demand_plan.py +++ b/sf_demand_plan/models/sf_production_demand_plan.py @@ -344,9 +344,11 @@ class SfProductionDemandPlan(models.Model): pro_plan.do_production_schedule() def update_sale_order_state(self): - demand_plan = self.env['sf.demand.plan'].sudo().search([('sale_order_id', '=', self.sale_order_id.id)]) - demand_plan_state = demand_plan.filtered(lambda line: line.state != '40') - if not demand_plan_state: + # demand_plan = self.env['sf.demand.plan'].sudo().search([('sale_order_id', '=', self.sale_order_id.id)]) + # demand_plan_state = demand_plan.filtered(lambda line: line.state != '40') + production_demand_plan = self.env['sf.production.demand.plan'].sudo().search([('sale_order_id', '=', self.sale_order_id.id)]) + production_demand_plan_state = production_demand_plan.filtered(lambda line: line.status in ('10', '20', '30')) + if not production_demand_plan_state: # 修改销售订单为加工中 self.sale_order_id.state = 'processing' @@ -675,6 +677,7 @@ class SfProductionDemandPlan(models.Model): self._action_launch_stock_rule() if self.supply_method in ('automation', 'manual'): self.write({'status': '50'}) + self.update_sale_order_state() else: self.write({'status': '60'}) self.update_sale_order_state()