From 5b2060f13a32f3653191b290d024f70f95bef1b4 Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Mon, 9 Jun 2025 11:53:19 +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_will_task/models/yuthon_will_task.py | 37 ++--- .../views/yuthon_will_task_views.xml | 137 ++++++++---------- 2 files changed, 83 insertions(+), 91 deletions(-) diff --git a/yuthon_will_task/models/yuthon_will_task.py b/yuthon_will_task/models/yuthon_will_task.py index f588d1687..7ec8512ea 100644 --- a/yuthon_will_task/models/yuthon_will_task.py +++ b/yuthon_will_task/models/yuthon_will_task.py @@ -74,7 +74,7 @@ class YuthonWillTask(models.Model): remarks = fields.Text(string='备注') creation_time = fields.Date(string='创建时间', default=fields.Date.today()) employee_ids = fields.Many2many('hr.employee', 'will_task_employee_rel', 'custom_id', 'employee_id', - string='人员', store=True, index=True, domain=lambda self: self._get_employee_domain()) + string='人员', store=True, index=True) employee_ids2 = fields.Many2many('hr.employee', 'will_task_employee_rel2', 'custom_id', 'employee_id', string='司机', store=True, index=True) users_ids = fields.Many2many('res.users', string='用户', store=True, index=True, default=lambda self: self.env.user) @@ -88,23 +88,24 @@ class YuthonWillTask(models.Model): @api.onchange('is_this_company') def _onchange_is_this_company(self): - """当是否为本公司字段变化时,更新员工列表和domain""" - if self.is_this_company: - # 获取当前用户所属的公司列表 - company_ids = self.env.companies.ids - # 过滤已选员工,只保留属于当前公司的员工 - self.employee_ids = self.employee_ids.filtered( - lambda emp: emp.company_id.id in company_ids - ) - # 返回domain,限制可选员工为当前公司的员工 - return { - 'domain': { - 'employee_ids': [('company_id', 'in', company_ids)] - } - } - else: - # 当不限制为本公司时,清空domain,允许选择所有员工 - return {'domain': {'employee_ids': []}} + pass + # """当是否为本公司字段变化时,更新员工列表和domain""" + # if self.is_this_company: + # # 获取当前用户所属的公司列表 + # company_ids = self.env.companies.ids + # # 过滤已选员工,只保留属于当前公司的员工 + # self.employee_ids = self.employee_ids.filtered( + # lambda emp: emp.company_id.id in company_ids + # ) + # # 返回domain,限制可选员工为当前公司的员工 + # return { + # 'domain': { + # 'employee_ids': [('company_id', 'in', company_ids)] + # } + # } + # else: + # # 当不限制为本公司时,清空domain,允许选择所有员工 + # return {'domain': {'employee_ids': []}} @api.onchange('employee_ids', 'user_id') def _onchange_employee_ids(self): diff --git a/yuthon_will_task/views/yuthon_will_task_views.xml b/yuthon_will_task/views/yuthon_will_task_views.xml index 01c33e4b5..c3e9c9c20 100644 --- a/yuthon_will_task/views/yuthon_will_task_views.xml +++ b/yuthon_will_task/views/yuthon_will_task_views.xml @@ -42,83 +42,74 @@ - yuthon.will.task.form - yuthon.will.task - -
- - - - - - - - - - - - - - - - -
-
+ yuthon.will.task.form + yuthon.will.task + + + + + + + + + - - - - - - - - - - - - + - - - - - - - - - - - - + + - -
- - - -
- -
-
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + yuthon.will.task.tree2 yuthon.will.task @@ -216,7 +207,7 @@
- +