[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] 826f927a1e
Task: 1935077

closes odoo/odoo#30685
This commit is contained in:
Prakash Prajapati
2019-02-01 10:36:14 +00:00
committed by Simon Lejeune
parent ff368fdbd5
commit 8a25e58ed2
@@ -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