[FIX] stock: fix picking_type_id of stock move.

The picking_type_id of a stock move can differ of the related picking:
- Create and save a draft transfer with a stock move
- Change the picking_type_id and save
- The picking_type of moves won't be the same than the one on the stock
picking.
Fix force the picking_type_id of moves_lines in the
picking `onchange_picking_type` method. Same issue can appear in multi
company situation, fix it too.

task-2372196

closes odoo/odoo#61574

Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
This commit is contained in:
Rémy Voet (ryv)
2020-11-10 10:44:11 +00:00
committed by Arnold Moyaux
parent e65d6e422f
commit 6f87a849ac
+7 -5
View File
@@ -568,7 +568,7 @@ class Picking(models.Model):
@api.onchange('picking_type_id', 'partner_id')
def onchange_picking_type(self):
if self.picking_type_id:
if self.picking_type_id and self.state == 'draft':
self = self.with_company(self.company_id)
if self.picking_type_id.default_location_src_id:
location_id = self.picking_type_id.default_location_src_id.id
@@ -584,11 +584,13 @@ class Picking(models.Model):
else:
location_dest_id, supplierloc = self.env['stock.warehouse']._get_partner_locations()
if self.state == 'draft':
self.location_id = location_id
self.location_dest_id = location_dest_id
self.location_id = location_id
self.location_dest_id = location_dest_id
(self.move_lines | self.move_ids_without_package).update({
"picking_type_id": self.picking_type_id,
"company_id": self.company_id,
})
# TDE CLEANME move into onchange_partner_id
if self.partner_id and self.partner_id.picking_warn:
if self.partner_id.picking_warn == 'no-message' and self.partner_id.parent_id:
partner = self.partner_id.parent_id