From ec31150d18460f676c2bf400729389b992e1d8cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Wed, 6 May 2026 20:14:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=8F=9C=E5=8D=95=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_base/__manifest__.py | 1 + yuthon_base/models/res_users.py | 28 +--------------------------- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/yuthon_base/__manifest__.py b/yuthon_base/__manifest__.py index fc9fdca6f..00b5706a4 100644 --- a/yuthon_base/__manifest__.py +++ b/yuthon_base/__manifest__.py @@ -8,6 +8,7 @@ 'license': 'LGPL-3', 'data': [ 'security/ir.model.access.csv', + 'data/res_users_data.xml', 'views/system_version_views.xml', 'views/system_logs_views.xml', 'views/ir_cron_act_views.xml', diff --git a/yuthon_base/models/res_users.py b/yuthon_base/models/res_users.py index e8026b390..93f65c94c 100644 --- a/yuthon_base/models/res_users.py +++ b/yuthon_base/models/res_users.py @@ -5,36 +5,10 @@ from odoo import api, models class ResUsers(models.Model): _inherit = 'res.users' - @api.model - def default_get(self, fields_list): - res = super().default_get(fields_list) - # 新建用户时默认不勾选财务管理员权限组 - if 'groups_id' in res: - group_manager = self.env.ref('account.group_account_manager', raise_if_not_found=False) - group_invoice = self.env.ref('account.group_account_invoice', raise_if_not_found=False) - groups_to_remove = set() - if group_manager: - groups_to_remove.add(group_manager.id) - if group_invoice: - groups_to_remove.add(group_invoice.id) - if groups_to_remove: - # groups_id 在 default_get 中可能是 [(6, 0, [ids])] 或 [ids] 格式 - groups_value = res['groups_id'] - if groups_value and isinstance(groups_value[0], (list, tuple)): - # [(6, 0, [ids])] 格式 - for i, cmd in enumerate(groups_value): - if cmd[0] == 6: - filtered_ids = [gid for gid in cmd[2] if gid not in groups_to_remove] - groups_value[i] = (6, 0, filtered_ids) - else: - # [ids] 格式 - res['groups_id'] = [gid for gid in groups_value if gid not in groups_to_remove] - return res - @api.model_create_multi def create(self, vals_list): users = super().create(vals_list) - # 新建用户后再次确保移除财务管理员权限组 + # 新建用户后确保移除财务管理员权限组 groups_to_remove = [] group_manager = self.env.ref('account.group_account_manager', raise_if_not_found=False) group_invoice = self.env.ref('account.group_account_invoice', raise_if_not_found=False) From 26e1a8227a6402503d166d4e1a8f0f8dd0ff14e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Wed, 6 May 2026 20:14:48 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=8F=9C=E5=8D=95=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_base/data/res_users_data.xml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 yuthon_base/data/res_users_data.xml diff --git a/yuthon_base/data/res_users_data.xml b/yuthon_base/data/res_users_data.xml new file mode 100644 index 000000000..3f34e3b77 --- /dev/null +++ b/yuthon_base/data/res_users_data.xml @@ -0,0 +1,7 @@ + + + + + + +