diff --git a/addons/hr/models/hr_contract_type.py b/addons/hr/models/hr_contract_type.py
index 03aadc6f134..7e540b7b16f 100644
--- a/addons/hr/models/hr_contract_type.py
+++ b/addons/hr/models/hr_contract_type.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
-from odoo import fields, models
+from odoo import api, fields, models
class ContractType(models.Model):
@@ -10,5 +10,13 @@ class ContractType(models.Model):
_order = 'sequence'
name = fields.Char(required=True, translate=True)
+ code = fields.Char(compute='_compute_code', store=True, readonly=False)
sequence = fields.Integer()
country_id = fields.Many2one('res.country')
+
+ @api.depends('name')
+ def _compute_code(self):
+ for contract_type in self:
+ if contract_type.code:
+ continue
+ contract_type.code = contract_type.name
diff --git a/addons/hr/security/hr_security.xml b/addons/hr/security/hr_security.xml
index 3238b7d7f12..ddf2ef03351 100644
--- a/addons/hr/security/hr_security.xml
+++ b/addons/hr/security/hr_security.xml
@@ -90,7 +90,7 @@
HR Contract Type: Multi Company
- ['|', ('country_id', '=', False), ('country_id', 'in', user.env.companies.mapped('country_id').ids)]
+ ['|', ('country_id', '=', False), ('country_id', 'in', user.env.companies.country_id.ids)]
diff --git a/addons/hr/views/hr_contract_type_views.xml b/addons/hr/views/hr_contract_type_views.xml
index ccfc0caca1a..9c8bc36462b 100644
--- a/addons/hr/views/hr_contract_type_views.xml
+++ b/addons/hr/views/hr_contract_type_views.xml
@@ -7,6 +7,7 @@
+
@@ -19,6 +20,7 @@
+