Skip to content
Snippets Groups Projects
Commit aa0fb325 authored by William Henrotin's avatar William Henrotin
Browse files

[FIX] stock_account: remove order in read_group


`quantity_svl` and `value_svl` field on product_product are computed from all the stock_valuation_layers
As no `orderby` key is given, the `groupby` keys are used as orderby
ones. In this particular case, the groups are done on `product_id` so
the order is on the name of product_product. This order will add to the
read_group query 3 joins from stock_valuation_layer table.
  - product_product
  - product_template for the name
  - ir_translation for the translation of the name

This is completely useless in the scope of a computed field to get the
sum of values and sum of quantities. As it not possible to ask
read_group to not order the result. This commit call the method with the
simplest order key possible: `id`

closes odoo/odoo#105921

Opw: 3047017
Signed-off-by: default avatarArnold Moyaux (arm) <arm@odoo.com>
parent 4bd6f422
Branches
Tags
No related merge requests found
......@@ -117,7 +117,7 @@ class ProductProduct(models.Model):
if self.env.context.get('to_date'):
to_date = fields.Datetime.to_datetime(self.env.context['to_date'])
domain.append(('create_date', '<=', to_date))
groups = self.env['stock.valuation.layer'].read_group(domain, ['value:sum', 'quantity:sum'], ['product_id'])
groups = self.env['stock.valuation.layer'].read_group(domain, ['value:sum', 'quantity:sum'], ['product_id'], orderby='id')
products = self.browse()
for group in groups:
product = self.browse(group['product_id'][0])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment