[FIX] mrp_subcontracting_dropshipping: technical fields should not trigger UserError
As a display line does not need to fulfill the dropship check, we skip those and we do give the user a hint which lines are potentially not fulfilling the check. Reproduce: - Create a purchases order with a picking type for dropshipping - Add a different destination address (i.e. of another subcontractor to follow up the next manufacturing process) - Add products with a defined BoM with type subcontractor and vendor - Additionally add a section or a note - Try to confirm the purchase order Result: - A user error will be triggered about a line which does not fit the current use case Solution: - as a section or a note should not be checked we do not trigger for those - for other products which do not fit the use case we let the user know which lines are blocking closes odoo/odoo#115044 X-original-commit: 5ba435d1ece208453fc73993b8018c68bb5f889d Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
This commit is contained in:
committed by
Arnold Moyaux
parent
4d07f55335
commit
fcbf264d52
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user