diff options
| author | Rémy Voet (ryv) <ryv@odoo.com> | 2020-10-28 14:19:23 +0000 |
|---|---|---|
| committer | Arnold Moyaux <arm@odoo.com> | 2020-11-10 09:23:26 +0000 |
| commit | cdafba2fdbfc8ddd13cda180b287d3128fe00ae6 (patch) | |
| tree | b5b3d893cb400cd75013528d50705dd80c225b7e /addons/stock/models | |
| parent | 236094958785ed3e642e1b89d45a056fa2c8a8b2 (diff) | |
[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#60914
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Diffstat (limited to 'addons/stock/models')
| -rw-r--r-- | addons/stock/models/stock_picking.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index dac52635fa0..1f1fb0acbc9 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -574,7 +574,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 @@ -590,11 +590,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 |
