[IMP] account: make sequence indexable
the search for sequence include a criteria `date_trunc('year', date) =
date_trunc('year', '2017-10-01'::date)` Which is translated by query
planner in `date_trunc('year'::text, date::timestamp with time zone)`.
As it's mutable thanks to the time zone, it's not indexable. Enforcing
the `without timezone` makes the query planner use an immutable
`date_trunc('year'::text, date::timestamp without time zone)`. As it's
immutable, it's indexable.
closes odoo/odoo#56244
X-original-commit: 70f671a32a504c6aa92fd19e38e6151c10b2325b
Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
This commit is contained in:
@@ -1038,10 +1038,10 @@ class AccountMove(models.Model):
|
||||
reference_move = self.search(domain + [('date', '<=', self.date)], order='date desc', limit=1) or self.search(domain, order='date asc', limit=1)
|
||||
sequence_number_reset = self._deduce_sequence_number_reset(reference_move.name)
|
||||
if sequence_number_reset == 'year':
|
||||
where_string += " AND date_trunc('year', date) = date_trunc('year', %(date)s) "
|
||||
where_string += " AND date_trunc('year', date::timestamp without time zone) = date_trunc('year', %(date)s) "
|
||||
param['date'] = self.date
|
||||
elif sequence_number_reset == 'month':
|
||||
where_string += " AND date_trunc('month', date) = date_trunc('month', %(date)s) "
|
||||
where_string += " AND date_trunc('month', date::timestamp without time zone) = date_trunc('month', %(date)s) "
|
||||
param['date'] = self.date
|
||||
|
||||
if self.journal_id.refund_sequence:
|
||||
|
||||
Reference in New Issue
Block a user