From b38a5f78b6d57af15e993b09201fe7f7fcb22be9 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Thu, 18 Aug 2022 14:22:50 +0000 Subject: [PATCH] [FIX] *: avoid non-searchable field dependencies closes odoo/odoo#98562 Related: odoo/enterprise#30639 Signed-off-by: Raphael Collet --- addons/account/models/account_move.py | 2 +- addons/account/models/company.py | 2 +- addons/fleet/models/fleet_vehicle.py | 2 +- addons/hr/models/hr_employee.py | 2 +- addons/hr_contract/models/hr_contract.py | 2 +- addons/hr_contract/report/hr_contract_history.py | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 04b15ec062e..967d79ad2f9 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -1218,7 +1218,7 @@ class AccountMove(models.Model): else: record.tax_country_id = record.company_id.account_fiscal_country_id - @api.depends('tax_country_id.code') + @api.depends('tax_country_id') def _compute_tax_country_code(self): for record in self: record.tax_country_code = record.tax_country_id.code diff --git a/addons/account/models/company.py b/addons/account/models/company.py index 94b969edb26..5785b096074 100644 --- a/addons/account/models/company.py +++ b/addons/account/models/company.py @@ -136,7 +136,7 @@ class ResCompany(models.Model): automatic_entry_default_journal_id = fields.Many2one('account.journal', help="Journal used by default for moving the period of an entry", domain="[('type', '=', 'general')]") # Technical field to hide country specific fields in company form view - country_code = fields.Char(related='country_id.code') + country_code = fields.Char(related='country_id.code', depends=['country_id']) # Taxes account_fiscal_country_id = fields.Many2one( diff --git a/addons/fleet/models/fleet_vehicle.py b/addons/fleet/models/fleet_vehicle.py index 0c177840250..5b438f0eb67 100644 --- a/addons/fleet/models/fleet_vehicle.py +++ b/addons/fleet/models/fleet_vehicle.py @@ -41,7 +41,7 @@ class FleetVehicle(models.Model): ) currency_id = fields.Many2one('res.currency', related='company_id.currency_id') country_id = fields.Many2one('res.country', related='company_id.country_id') - country_code = fields.Char(related='country_id.code') + country_code = fields.Char(related='country_id.code', depends=['country_id']) license_plate = fields.Char(tracking=True, help='License plate number of the vehicle (i = plate number for a car)') vin_sn = fields.Char('Chassis Number', help='Unique number written on the vehicle motor (VIN/SN number)', copy=False) diff --git a/addons/hr/models/hr_employee.py b/addons/hr/models/hr_employee.py index a365d9f1eec..bfeb38e49b1 100644 --- a/addons/hr/models/hr_employee.py +++ b/addons/hr/models/hr_employee.py @@ -37,7 +37,7 @@ class HrEmployeePrivate(models.Model): active = fields.Boolean('Active', related='resource_id.active', default=True, store=True, readonly=False) company_id = fields.Many2one('res.company', required=True) company_country_id = fields.Many2one('res.country', 'Company Country', related='company_id.country_id', readonly=True) - company_country_code = fields.Char(related='company_country_id.code', readonly=True) + company_country_code = fields.Char(related='company_country_id.code', depends=['company_country_id'], readonly=True) # private partner address_home_id = fields.Many2one( 'res.partner', 'Address', help='Enter here the private address of the employee, not the one linked to your company.', diff --git a/addons/hr_contract/models/hr_contract.py b/addons/hr_contract/models/hr_contract.py index 4b362d31ba0..5b2734dbb99 100644 --- a/addons/hr_contract/models/hr_contract.py +++ b/addons/hr_contract/models/hr_contract.py @@ -45,7 +45,7 @@ class Contract(models.Model): company_id = fields.Many2one('res.company', compute='_compute_employee_contract', store=True, readonly=False, default=lambda self: self.env.company, required=True) company_country_id = fields.Many2one('res.country', string="Company country", related='company_id.country_id', readonly=True) - country_code = fields.Char(related='company_country_id.code', readonly=True) + country_code = fields.Char(related='company_country_id.code', depends=['company_country_id'], readonly=True) contract_type_id = fields.Many2one('hr.contract.type', "Contract Type") """ diff --git a/addons/hr_contract/report/hr_contract_history.py b/addons/hr_contract/report/hr_contract_history.py index ef50bbb4842..aa1c18d5185 100644 --- a/addons/hr_contract/report/hr_contract_history.py +++ b/addons/hr_contract/report/hr_contract_history.py @@ -39,7 +39,7 @@ class ContractHistory(models.Model): wage = fields.Monetary('Wage', help="Employee's monthly gross wage.", readonly=True, group_operator="avg") company_id = fields.Many2one('res.company', string='Company', readonly=True) company_country_id = fields.Many2one('res.country', string="Company country", related='company_id.country_id', readonly=True) - country_code = fields.Char(related='company_country_id.code', readonly=True) + country_code = fields.Char(related='company_country_id.code', depends=['company_country_id'], readonly=True) currency_id = fields.Many2one(string='Currency', related='company_id.currency_id', readonly=True) contract_type_id = fields.Many2one('hr.contract.type', 'Contract Type', readonly=True) contract_ids = fields.One2many('hr.contract', string='Contracts', compute='_compute_contract_ids', readonly=True)