diff --git a/sf_demand_plan/models/sf_production_demand_plan.py b/sf_demand_plan/models/sf_production_demand_plan.py index de902573..d484fb8e 100644 --- a/sf_demand_plan/models/sf_production_demand_plan.py +++ b/sf_demand_plan/models/sf_production_demand_plan.py @@ -363,10 +363,9 @@ class SfProductionDemandPlan(models.Model): ) if total_purchase_quantity < record.product_uom_qty: pr_ids = self.env['purchase.request'].sudo().search( - [('origin', 'like', mrp_production[0].name), ('state', '!=', 'done')]) + [('line_ids.product_id', 'in', raw_materials.ids), ('state', '!=', 'done')]) outsourcing_purchase_request.extend(pr_ids.ids) elif record.supply_method in ('purchase', 'outsourcing'): - pr_ids = None purchase_orders = self.env['purchase.order'].sudo().search([ ('state', 'in', ('purchase', 'done')), ('order_line.product_id', '=', record.product_id.id)