[IMP] pos: add some indexes to speedup Tax Report

Tax Report _compute_from_amls_grids query calls
two method overriden in pos_account_reports.

The resulting query contains EXISTS subqueries on pos_session.move_id
and pos_order.account_move. Because these two fields are not indexed
by default, the cost of the query can skyrocket in large databases,
leading to slow tax report generation.

closes odoo/odoo#99095

X-original-commit: 51e607a70be804b0cd614cccc36ea0145c934676
Signed-off-by: Rémy Voet <ryv@odoo.com>
This commit is contained in:
Aurélien (avd)
2022-09-02 08:14:47 +02:00
parent 82ae8ba0f0
commit d6dc795e20
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -265,7 +265,7 @@ class PosOrder(models.Model):
[('draft', 'New'), ('cancel', 'Cancelled'), ('paid', 'Paid'), ('done', 'Posted'), ('invoiced', 'Invoiced')],
'Status', readonly=True, copy=False, default='draft')
account_move = fields.Many2one('account.move', string='Invoice', readonly=True, copy=False)
account_move = fields.Many2one('account.move', string='Invoice', readonly=True, copy=False, index=True)
picking_ids = fields.One2many('stock.picking', 'pos_order_id')
picking_count = fields.Integer(compute='_compute_picking_count')
failed_pickings = fields.Boolean(compute='_compute_picking_count')
+1 -1
View File
@@ -92,7 +92,7 @@ class PosSession(models.Model):
help="Auto-generated session for orphan orders, ignored in constraints",
readonly=True,
copy=False)
move_id = fields.Many2one('account.move', string='Journal Entry')
move_id = fields.Many2one('account.move', string='Journal Entry', index=True)
payment_method_ids = fields.Many2many('pos.payment.method', related='config_id.payment_method_ids', string='Payment Methods')
total_payments_amount = fields.Float(compute='_compute_total_payments_amount', string='Total Payments Amount')
is_in_company_currency = fields.Boolean('Is Using Company Currency', compute='_compute_is_in_company_currency')