Files
odoo_source/addons/purchase_requisition_stock/models/purchase.py
T
Prakash Prajapati 8a25e58ed2 [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
2019-02-01 10:36:14 +00:00

15 lines
453 B
Python

# -*- encoding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
class PurchaseOrder(models.Model):
_inherit = 'purchase.order'
@api.onchange('requisition_id')
def _onchange_requisition_id(self):
super(PurchaseOrder, self)._onchange_requisition_id()
if self.requisition_id:
self.picking_type_id = self.requisition_id.picking_type_id.id