[FIX] point_of_sale: add missing indexes for create_from_ui

Add two missing indexes on pos.order and one on pos.payment. These
speed up queries executed when calling create_from_ui from the
pos interface.

opw-3619270

closes odoo/odoo#151441

X-original-commit: 6f1b5bd530dbb211bb0dbc41b523233dfb57d002
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
Signed-off-by: Aurélien van Delft (avd) <avd@odoo.com>
This commit is contained in:
Aurelien van Delft (avd)
2024-01-31 04:37:43 +00:00
parent 3f1318a247
commit 7eabfd06fe
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -298,7 +298,7 @@ class PosOrder(models.Model):
is_total_cost_computed = fields.Boolean(compute='_compute_is_total_cost_computed',
help="Allows to know if all the total cost of the order lines have already been computed")
lines = fields.One2many('pos.order.line', 'order_id', string='Order Lines', copy=True)
company_id = fields.Many2one('res.company', string='Company', required=True, readonly=True)
company_id = fields.Many2one('res.company', string='Company', required=True, readonly=True, index=True)
country_code = fields.Char(related='company_id.account_fiscal_country_id.code')
pricelist_id = fields.Many2one('product.pricelist', string='Pricelist')
partner_id = fields.Many2one('res.partner', string='Customer', change_default=True, index='btree_not_null')
@@ -325,7 +325,7 @@ class PosOrder(models.Model):
note = fields.Text(string='Internal Notes')
nb_print = fields.Integer(string='Number of Print', readonly=True, copy=False, default=0)
pos_reference = fields.Char(string='Receipt Number', readonly=True, copy=False)
pos_reference = fields.Char(string='Receipt Number', readonly=True, copy=False, index=True)
sale_journal = fields.Many2one('account.journal', related='session_id.config_id.journal_id', string='Sales Journal', store=True, readonly=True, ondelete='restrict')
fiscal_position_id = fields.Many2one(
comodel_name='account.fiscal.position', string='Fiscal Position',
+1 -1
View File
@@ -16,7 +16,7 @@ class PosPayment(models.Model):
_order = "id desc"
name = fields.Char(string='Label', readonly=True)
pos_order_id = fields.Many2one('pos.order', string='Order', required=True)
pos_order_id = fields.Many2one('pos.order', string='Order', required=True, index=True)
amount = fields.Monetary(string='Amount', required=True, currency_field='currency_id', readonly=True, help="Total amount of the payment.")
payment_method_id = fields.Many2one('pos.payment.method', string='Payment Method', required=True)
payment_date = fields.Datetime(string='Date', required=True, readonly=True, default=lambda self: fields.Datetime.now())