[FIX] stock: missing picking type

- Activate 'Lots & Serial Numbers'
- Create a stockable product A, enable tracking 'By Lots'
- From the menu Inventory > Operations > Transfers, create a picking:
Set a picking type
One line of A

It is not possible to set the lot number to validate the transfer.

When creating a picking from the menu, the context key
`default_picking_type_id` is not set. Therefore, the field
`picking_type_id` is empty on the `stock.move`.

We can fall back on the `picking_type_id` of the picking.

opw-1981958

closes odoo/odoo#33611

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Nicolas Martinelli
2019-05-23 11:11:17 +00:00
parent 8869677669
commit 9f7c476a6f
+3 -2
View File
@@ -464,6 +464,7 @@ class StockMove(models.Model):
else:
view = self.env.ref('stock.view_stock_move_nosuggest_operations')
picking_type_id = self.picking_type_id or self.picking_id.picking_type_id
return {
'name': _('Detailed Operations'),
'type': 'ir.actions.act_window',
@@ -476,8 +477,8 @@ class StockMove(models.Model):
'res_id': self.id,
'context': dict(
self.env.context,
show_lots_m2o=self.has_tracking != 'none' and (self.picking_type_id.use_existing_lots or self.state == 'done' or self.origin_returned_move_id.id), # able to create lots, whatever the value of ` use_create_lots`.
show_lots_text=self.has_tracking != 'none' and self.picking_type_id.use_create_lots and not self.picking_type_id.use_existing_lots and self.state != 'done' and not self.origin_returned_move_id.id,
show_lots_m2o=self.has_tracking != 'none' and (picking_type_id.use_existing_lots or self.state == 'done' or self.origin_returned_move_id.id), # able to create lots, whatever the value of ` use_create_lots`.
show_lots_text=self.has_tracking != 'none' and picking_type_id.use_create_lots and not picking_type_id.use_existing_lots and self.state != 'done' and not self.origin_returned_move_id.id,
show_source_location=self.location_id.child_ids,
show_destination_location=self.location_dest_id.child_ids,
show_package=not self.location_id.usage == 'supplier',