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.
28 lines
1003 B
Python
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)
|