Files
Cédric Krier 5310b00496 Remove grouped_slice per IN_MAX
The usage of ``grouped_slice`` without size is deprecated since `=
ANY(ARRAY[%s])` is used for PostgreSQL and SQLite is used only for tests.

The ``Database.IN_MAX`` is replaced by ``backend.MAX_QUERY_PARAMS`` which is a
more accurate limit of the backend.
The SQLite limits is indeed SQLITE_MAX_EXPR_DEPTH so we use a empirical value.
2026-03-22 21:05:26 +01:00

28 lines
1003 B
Python

# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.pool import Pool, PoolMeta
class Product(metaclass=PoolMeta):
__name__ = 'product.product'
@classmethod
def recompute_cost_price(cls, products, start=None):
pool = Pool()
Move = pool.get('stock.move')
Shipment = pool.get('stock.shipment.drop')
shipments = set()
domain = [
('unit_price_updated', '=', True),
cls._domain_moves_cost(),
('product', 'in', products),
('shipment', 'like', 'stock.shipment.drop,%'),
]
if start:
domain.append(('effective_date', '>=', start))
for move in Move.search(domain, order=[]):
shipments.add(move.shipment)
shipments = Shipment.browse(list(shipments))
Shipment.set_cost(shipments)
super().recompute_cost_price(products, start=start)