diff --git a/addons/mrp_subcontracting_dropshipping/models/purchase.py b/addons/mrp_subcontracting_dropshipping/models/purchase.py index dbed48c5e79..c8cf393310c 100644 --- a/addons/mrp_subcontracting_dropshipping/models/purchase.py +++ b/addons/mrp_subcontracting_dropshipping/models/purchase.py @@ -31,14 +31,17 @@ class PurchaseOrder(models.Model): return super()._get_destination_location() in_bom_products = False - not_in_bom_products = False + not_in_bom_products = self.env['purchase.order.line'] for order_line in self.order_line: if any(bom_line.bom_id.type == 'subcontract' and self.dest_address_id in bom_line.bom_id.subcontractor_ids for bom_line in order_line.product_id.bom_line_ids.filtered(lambda line: line.company_id == self.company_id)): in_bom_products = True - else: - not_in_bom_products = True + elif not order_line.display_type: + not_in_bom_products |= order_line if in_bom_products and not_in_bom_products: - raise UserError(_("It appears some components in this RFQ are not meant for subcontracting. Please create a separate order for these.")) + raise UserError( + _("It appears some components in this RFQ are not meant for subcontracting. Please create a separate order for these.") + + '\n\n' + '\n'.join(not_in_bom_products.mapped('name')) + ) elif in_bom_products: return self.dest_address_id.property_stock_subcontractor.id return super()._get_destination_location()