From 0ff3ab2f2108a9a6c2f5551bece99132bd0c75a6 Mon Sep 17 00:00:00 2001 From: "Ahmed Khalaf (ahkh)" Date: Thu, 1 Sep 2022 15:14:01 +0000 Subject: [PATCH] [IMP] purchase_stock: remove onchange order pick type This commit removes onchange on picktype in PO replacing it with compute Part-of: odoo/odoo#95770 --- addons/purchase_stock/models/purchase.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/addons/purchase_stock/models/purchase.py b/addons/purchase_stock/models/purchase.py index e07d1a220f0..ec47a056c67 100644 --- a/addons/purchase_stock/models/purchase.py +++ b/addons/purchase_stock/models/purchase.py @@ -21,7 +21,7 @@ class PurchaseOrder(models.Model): incoterm_location = fields.Char(string='Incoterm Location', states={'done': [('readonly', True)]}) incoming_picking_count = fields.Integer("Incoming Shipment count", compute='_compute_incoming_picking_count') picking_ids = fields.Many2many('stock.picking', compute='_compute_picking_ids', string='Receptions', copy=False, store=True) - + dest_address_id = fields.Many2one('res.partner', compute='_compute_dest_address_id', store=True, readonly=False) picking_type_id = fields.Many2one('stock.picking.type', 'Deliver To', states=Purchase.READONLY_STATES, required=True, default=_default_picking_type, domain="['|', ('warehouse_id', '=', False), ('warehouse_id.company_id', '=', company_id)]", help="This will determine operation type of incoming shipment") default_location_dest_id_usage = fields.Selection(related='picking_type_id.default_location_dest_id.usage', string='Destination Location Type', @@ -73,10 +73,9 @@ class PurchaseOrder(models.Model): else: order.receipt_status = 'pending' - @api.onchange('picking_type_id') - def _onchange_picking_type_id(self): - if self.picking_type_id.default_location_dest_id.usage != 'customer': - self.dest_address_id = False + @api.depends('picking_type_id') + def _compute_dest_address_id(self): + self.filtered(lambda po: po.picking_type_id.default_location_dest_id.usage != 'customer').dest_address_id = False @api.onchange('company_id') def _onchange_company_id(self):