[FIX] purchase_stock: check if picking_type has a warehouse

Commit 643e093a4bc9d46973705831697036b56a89b143 adds a security on
orderpoints triggering purchase orders. But this new check fails in case
the picking type on the purchase order is not linked to a warehouse (e.g
in a subcontracting flow).

This commit ensure the check is done only if we have a warehouse linked
to the purchase order.

closes odoo/odoo#75619

Opw: 2631979
X-original-commit: 8343ce44d72c77f56937e1694606dc718497fbb8
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
This commit is contained in:
William Henrotin
2021-08-26 10:21:42 +00:00
parent 23915c7113
commit 19673b5c55
+1 -1
View File
@@ -470,7 +470,7 @@ class PurchaseOrderLine(models.Model):
def _check_orderpoint_picking_type(self):
warehouse_loc = self.order_id.picking_type_id.warehouse_id.view_location_id
if self.orderpoint_id and not warehouse_loc.parent_path in self.orderpoint_id.location_id.parent_path:
if warehouse_loc and self.orderpoint_id and not warehouse_loc.parent_path in self.orderpoint_id.location_id.parent_path:
raise UserError(_('For the product %s, the warehouse of the operation type (%s) is inconsistent with the location (%s) of the reordering rule (%s). Change the operation type or cancel the request for quotation.',
self.product_id.display_name, self.order_id.picking_type_id.display_name, self.orderpoint_id.location_id.display_name, self.orderpoint_id.display_name))