[FIX] stock: force group by date when ordered by date

When displaying forecasted inventory if there is no default order,
the default order forced on date and id. In that case, if the date is
not in the "group by", it causes warning.

With this commit, the date is forced in the SQL view.

closes odoo/odoo#32633

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
This commit is contained in:
Arnold Moyaux
2019-04-11 15:43:21 +00:00
parent 8c642167e9
commit e5b19bd5aa
+2 -1
View File
@@ -129,6 +129,8 @@ class ReportStockForecat(models.Model):
WHERE
final.product_qty != 0 OR final.reference = 'Starting Inventory'
%s
ORDER BY
date
)
""" % (self._select(), self._left_join(), self._groupby())
self.env.cr.execute(query)
@@ -185,7 +187,6 @@ class ReportStockForecat(models.Model):
order to analyze different quantities in different situations.
"""
# Sort result by date_expected and id.
orderby = 'date, id' if not orderby else orderby
if 'cumulative_quantity' in fields and 'quantity' not in fields:
fields.append('quantity')
res = super(ReportStockForecat, self).read_group(domain, fields, groupby, offset=offset, limit=limit, orderby=orderby, lazy=lazy)