[FIX] stock: traceability report traceback with productions

use case to reproduce:

    receipt a product tracked by lot
    produce a lot with a component tracked*
    open the traceability report for the lot's component

you have a traceback.

it's due to last_delivery_partner_id field present in the tree view of lots.
it triggers _compute_delivery_ids that call _find_delivery_ids_by_lot in multi.
the call in the recursion(trigger by *) redefine delivery_by_lot and erase the previous result.
so the cache is not correctly update and traceback

closes odoo/odoo#82351

X-original-commit: e6bcc77c58d39adbd782e776eb2f6d5c470eb0e2
Signed-off-by: Arnold Moyaux <arm@odoo.com>
This commit is contained in:
Hardik Prajapati
2022-01-06 19:30:57 +00:00
parent fef39f82ac
commit 435730da10
+4 -3
View File
@@ -188,7 +188,7 @@ class StockLot(models.Model):
})
return action
def _find_delivery_ids_by_lot(self, lot_path=None):
def _find_delivery_ids_by_lot(self, lot_path=None, delivery_by_lot=None):
if lot_path is None:
lot_path = set()
@@ -198,7 +198,8 @@ class StockLot(models.Model):
'|', ('picking_code', '=', 'outgoing'), ('produce_line_ids', '!=', False)
]
move_lines = self.env['stock.move.line'].search(domain)
delivery_by_lot = dict()
if delivery_by_lot is None:
delivery_by_lot = dict()
for lot in self:
delivery_ids = set()
if lot.id in lot_path:
@@ -208,7 +209,7 @@ class StockLot(models.Model):
# Do the same process for lot_id contained in produce_line_ids,
# to fetch the end product deliveries
lot_path.add(lot.id)
for delivery_ids_set in line.produce_line_ids.lot_id._find_delivery_ids_by_lot(lot_path=lot_path).values():
for delivery_ids_set in line.produce_line_ids.lot_id._find_delivery_ids_by_lot(lot_path=lot_path, delivery_by_lot=delivery_by_lot).values():
delivery_ids.update(delivery_ids_set)
else:
delivery_ids.add(line.picking_id.id)