When I try to inventory a location where the products_by_location method return a dictionary with +2000 keys, the server is not able to complete the loop
for product in Product.browse([line for line in pbl]):
To solve the problem I could:
Open a transaction modifying the context ‘_record_cache_size’ and set the limit over the products_by_location entires.
Change the tryton config entry related to the cache size.
But the underlying problem stands. So perhaps, it would be needed a change in the code.
I tired using a search instead of browse:
for product in Product.search([('id', 'in', [key for key, value in pbl.items() if value])])
Cause it’s not needed to check more than one time for the same product with different lot, the type or if it is a consumable and also don’t need to check it if there is no product stock as it’s done currently.
If this modification is done, also is needed to check if the product id exists in the dictionary there
product2type.get(product_id,'') not in ['goods', 'assets'] or product2consumable.get(product_id, False)
It seems to solve the problem but I’m not sure what’s the best way to deal with this type of cache problems and if I should create an issue.