diff --git a/yuthon_hr_employee/models/yuthon_hr_employee.py b/yuthon_hr_employee/models/yuthon_hr_employee.py index 4f6536fb4..81ee464ab 100644 --- a/yuthon_hr_employee/models/yuthon_hr_employee.py +++ b/yuthon_hr_employee/models/yuthon_hr_employee.py @@ -33,6 +33,17 @@ class YuthonHrEmployee(models.Model): compress_image = fields.Binary(string="压缩头像", attachment=True) wecom_userid = fields.Char(string="成员UserID", related="user_id.oauth_uid") company_ids = fields.Many2many('res.company', related="user_id.company_ids") + role_allowed_company_ids = fields.Many2many('res.company', compute='_compute_role_allowed_company_ids') + + @api.depends('company_ids') + def _compute_role_allowed_company_ids(self): + thtz = self.env['res.company'].search([('name', '=', '天河投资集团')], limit=1) + for rec in self: + companies = rec.company_ids + if thtz and thtz not in companies: + companies |= thtz + rec.role_allowed_company_ids = companies + number = fields.Char(string="序号", store=True) is_soldiers = fields.Boolean(string="是否为退伍军人") user_number = fields.Char(string="员工编号", default=lambda self: self.env['ir.sequence'].next_by_code('employee_code')) diff --git a/yuthon_hr_employee/views/yuthon_hr_employee_views.xml b/yuthon_hr_employee/views/yuthon_hr_employee_views.xml index 3e9af5b3d..3429e8dbd 100644 --- a/yuthon_hr_employee/views/yuthon_hr_employee_views.xml +++ b/yuthon_hr_employee/views/yuthon_hr_employee_views.xml @@ -139,10 +139,11 @@ - + + domain="[('company_id', 'in', role_allowed_company_ids), ('is_main', '!=', True)]" options="{'no_open': True, 'no_create': True}"/> ztree_select