[FIX] stock: duplicate picking on push rules

Usecase:
- 2 warehouses 1 and 2
- Create a route with a rule from inter-warehouse to WH2
- Create a picking type for WH1 for stock to inter-warehouse
- Create a planned transfer with 2 stock.move in the wH1 new picking
type
-* Go back to inventory overview
- Click on process on the picking type WH1 -> inter-warehouse
-* Process the picking created before
- Go to WH2 delivery

You see 2 pickings for each stock.move despite they share the same
data (procurement group, source and dest locations)
If you don't do the steps bewteen *, you only have 1 picking.

It's due to the context of the views that is propagate to the
new picking created by push rules.

opw-2533718

closes odoo/odoo#76821

X-original-commit: 60c7722eedc1835a8aca9d6bbd75f5ab66ea4b59
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
This commit is contained in:
Arnold Moyaux
2021-09-21 09:38:02 +00:00
parent b717423f09
commit f7290fc9fe
+2 -2
View File
@@ -11,7 +11,7 @@ from odoo import _, api, fields, models
from odoo.exceptions import UserError
from odoo.osv import expression
from odoo.tools.float_utils import float_compare, float_is_zero, float_round
from odoo.tools.misc import OrderedSet
from odoo.tools.misc import clean_context, OrderedSet
PROCUREMENT_PRIORITIES = [('0', 'Normal'), ('1', 'Urgent')]
@@ -1175,7 +1175,7 @@ class StockMove(models.Model):
# assign picking in batch for all confirmed move that share the same details
for moves_ids in to_assign.values():
self.browse(moves_ids)._assign_picking()
self.browse(moves_ids).with_context(clean_context(self.env.context))._assign_picking()
new_push_moves = self.filtered(lambda m: not m.picking_id.immediate_transfer)._push_apply()
self._check_company()
moves = self