[IMP] Synchronize Picking Type and Warehouse

[IMP] User write()
This commit is contained in:
scampbell
2020-05-15 13:55:59 -07:00
committed by ps-tubtim
parent f83c7e0ebf
commit 8384fcd0eb

View File

@@ -19,3 +19,12 @@ class StockRequestOrder(models.Model):
picking_type_id = fields.Many2one(
'stock.picking.type', 'Operation Type',
default=_get_default_picking_type, required=True)
@api.onchange('warehouse_id')
def onchange_warehouse_picking_id(self):
if self.warehouse_id:
picking_type_id = self.env['stock.picking.type'].\
search([('code', '=', 'stock_request_order'),
('warehouse_id', '=', self.warehouse_id.id)], limit=1)
if picking_type_id:
self._origin.write({'picking_type_id': picking_type_id.id})