From 8a25e58ed2848705fa905446212c47fdf3205afa Mon Sep 17 00:00:00 2001 From: Prakash Prajapati Date: Wed, 30 Jan 2019 10:16:14 +0000 Subject: [PATCH] [FIX] purchase_requisition_stock: onchange and picking type Issue: - Create a RFQ for a stockable product - Try to validate - A required field "deliver to" (picking_type_id) is not set Rev [1] moved the stock related part of purchase_requisition to purchase_requisition_stock. It implements an onchange on the purchase order setting the picking_type_id of the one of the requisition. When no requisition is set, it wiped the default one. We fix the issue by only using the picking type of the requisition if a requisition is actually set. [1] 826f927a1ed54f6e2468e8f3b8649c1b7cfdf04b Task: 1935077 closes odoo/odoo#30685 --- addons/purchase_requisition_stock/models/purchase.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/purchase_requisition_stock/models/purchase.py b/addons/purchase_requisition_stock/models/purchase.py index 344fc1b8ea7..9debe4e8297 100644 --- a/addons/purchase_requisition_stock/models/purchase.py +++ b/addons/purchase_requisition_stock/models/purchase.py @@ -10,4 +10,5 @@ class PurchaseOrder(models.Model): @api.onchange('requisition_id') def _onchange_requisition_id(self): super(PurchaseOrder, self)._onchange_requisition_id() - self.picking_type_id = self.requisition_id.picking_type_id.id + if self.requisition_id: + self.picking_type_id = self.requisition_id.picking_type_id.id