From 9e6ac6b1ae6f13b5454b7e6d6a5afa57efa43274 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?=
<9664676+pengyuthon@user.noreply.gitee.com>
Date: Mon, 6 Jul 2026 12:00:33 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
yuthon_hr_employee/models/yuthon_hr_employee.py | 11 +++++++++++
yuthon_hr_employee/views/yuthon_hr_employee_views.xml | 5 +++--
2 files changed, 14 insertions(+), 2 deletions(-)
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