[IMP] remove unused indexes (field index included in unique index)

account.account: code was already in unique constraint
account.journal: inverting compound unique constraint to benefit from indexing company_id
hr.employee: user_id already in unique index
phone.blacklist: number already in unique index
stock.orderpoint: product_id already in unique constraint/index

closes odoo/odoo#92932

Signed-off-by: Fabien Pinckaers <fp@odoo.com>
This commit is contained in:
Fabien Pinckaers
2022-06-07 09:19:27 +02:00
parent bc1389ee89
commit c08fa433e4
5 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -61,7 +61,7 @@ class AccountAccount(models.Model):
name = fields.Char(string="Account Name", required=True, index='trigram', tracking=True)
currency_id = fields.Many2one('res.currency', string='Account Currency',
help="Forces all moves for this account to have this account currency.", tracking=True)
code = fields.Char(size=64, required=True, index=True, tracking=True)
code = fields.Char(size=64, required=True, tracking=True)
deprecated = fields.Boolean(default=False, tracking=True)
used = fields.Boolean(compute='_compute_used', search='_search_used')
user_type_id = fields.Many2one('account.account.type', string='Type', required=True, tracking=True,
+1 -1
View File
@@ -205,7 +205,7 @@ class AccountJournal(models.Model):
)
_sql_constraints = [
('code_company_uniq', 'unique (code, company_id)', 'Journal codes must be unique per company.'),
('code_company_uniq', 'unique (company_id, code)', 'Journal codes must be unique per company.'),
]
@api.depends('outbound_payment_method_line_ids', 'inbound_payment_method_line_ids')
+1 -1
View File
@@ -33,7 +33,7 @@ class HrEmployeePrivate(models.Model):
# resource and user
# required on the resource, make sure required="True" set in the view
name = fields.Char(string="Employee Name", related='resource_id.name', store=True, readonly=False, tracking=True)
user_id = fields.Many2one('res.users', 'User', related='resource_id.user_id', store=True, readonly=False, index=True)
user_id = fields.Many2one('res.users', 'User', related='resource_id.user_id', store=True, readonly=False)
user_partner_id = fields.Many2one(related='user_id.partner_id', related_sudo=False, string="User's partner")
active = fields.Boolean('Active', related='resource_id.active', default=True, store=True, readonly=False)
company_id = fields.Many2one('res.company', required=True)
@@ -17,7 +17,7 @@ class PhoneBlackList(models.Model):
_description = 'Phone Blacklist'
_rec_name = 'number'
number = fields.Char(string='Phone Number', required=True, index=True, tracking=True, help='Number should be E164 formatted')
number = fields.Char(string='Phone Number', required=True, tracking=True, help='Number should be E164 formatted')
active = fields.Boolean(default=True, tracking=True)
_sql_constraints = [
+1 -1
View File
@@ -62,7 +62,7 @@ class StockWarehouseOrderpoint(models.Model):
ondelete="cascade", required=True, check_company=True)
product_tmpl_id = fields.Many2one('product.template', related='product_id.product_tmpl_id')
product_id = fields.Many2one(
'product.product', 'Product', index=True,
'product.product', 'Product',
domain=lambda self: self._domain_product_id(),
ondelete='cascade', required=True, check_company=True)
product_category_id = fields.Many2one('product.category', name='Product Category', related='product_id.categ_id', store=True)