[IMP] sale: index to speed up constraint checks & open list view

closes odoo/odoo#99795

Related: odoo/enterprise#31148
Signed-off-by: Fabien Pinckaers <fp@odoo.com>
This commit is contained in:
Fabien Pinckaers
2022-09-08 12:46:50 +02:00
parent 1569100baa
commit 9b4e6331c4
+6 -1
View File
@@ -10,6 +10,7 @@ from odoo.exceptions import AccessError, UserError, ValidationError
from odoo.fields import Command
from odoo.osv import expression
from odoo.tools import float_is_zero, format_amount, format_date, html_keep_url, is_html_empty
from odoo.tools.sql import create_index
from odoo.addons.payment import utils as payment_utils
@@ -94,7 +95,7 @@ class SaleOrder(models.Model):
"this date rather than product lead times.")
date_order = fields.Datetime(
string="Order Date",
required=True, readonly=False, index=True, copy=False,
required=True, readonly=False, copy=False,
states=READONLY_FIELD_STATES,
help="Creation date of draft/sent orders,\nConfirmation date of confirmed orders.",
default=fields.Datetime.now)
@@ -285,6 +286,10 @@ class SaleOrder(models.Model):
show_update_pricelist = fields.Boolean(
string="Has Pricelist Changed", store=False) # True if the pricelist was changed
def init(self):
create_index(self._cr, 'sale_order_date_order_id_idx', 'sale_order', ["date_order desc", "id desc"])
#=== COMPUTE METHODS ===#
@api.depends('company_id')