[IMP] Set Picking Type in Create

[IMP] Flake8
This commit is contained in:
scampbell
2020-06-08 09:51:06 -07:00
committed by ps-tubtim
parent b135fa5899
commit 7df85bbe17

View File

@@ -28,3 +28,13 @@ class StockRequestOrder(models.Model):
('warehouse_id', '=', self.warehouse_id.id)], limit=1)
if picking_type_id:
self._origin.write({'picking_type_id': picking_type_id.id})
@api.model
def create(self, vals):
if vals.get('warehouse_id', False):
picking_type_id = self.env['stock.picking.type'].\
search([('code', '=', 'stock_request_order'),
('warehouse_id', '=', vals['warehouse_id'])], limit=1)
if picking_type_id:
vals.update({'picking_type_id': picking_type_id.id})
return super().create(vals)