Skip to content

Commit b755048

Browse files
committed
[PERF] stock: improve stock.move name_get memory usage
In the context of an export with a lot of records containing a 'stock.move' field (ex: stock.valuation.layer.stock_move_id): - Only the picking_id.origin, product_id.code and location(_dest)_id.name are needed. - Most of the data of picking_id, product_id and location(_dest)_id will be fetch and put in cache. This can result in a memory error as multiple thousands of records values (at the very least) will be stored in the cache. Customer cases: STOCK.MOVE: 350_000 BEFORE: 980 MB AFTER: 105 MB OPW-3911127 closes odoo#165059 Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
1 parent 3162011 commit b755048

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

addons/stock/models/stock_move.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ def default_get(self, fields_list):
572572

573573
def name_get(self):
574574
res = []
575-
for move in self:
575+
for move in self.with_context(prefetch_fields=False):
576576
res.append((move.id, '%s%s%s>%s' % (
577577
move.picking_id.origin and '%s/' % move.picking_id.origin or '',
578578
move.product_id.code and '%s: ' % move.product_id.code or '',

0 commit comments

Comments
 (0)