Merge pull request !3546 from 李鹏宇/dev
This commit is contained in:
李鹏宇
2025-06-27 09:06:00 +00:00
committed by Gitee
4 changed files with 56 additions and 44 deletions
@@ -130,7 +130,7 @@
<field name="type">ir.actions.act_window</field>
<field name="res_model">soong.workflow.record</field>
<field name="view_mode">tree,kanban,search</field>
<field name="domain">[('reclaim_state', '=', False), '|', ('approvals_group_id.name', '=', '人力资源'), ('approvals_group_id.name', '=', '考勤')]</field>
<field name="domain">[('reclaim_state', '=', False), '|', ('approvals_group_id.name', '=', '人力资源'), ('approvals_group_id.name', '=', '考勤'), ('member_of_department', '=', True)]</field>
<field name="search_view_id" ref="soong_workflow_record_search"/>
</record>
<record id="soong_workflow_other_record_action" model="ir.actions.act_window">
@@ -160,7 +160,5 @@
<field name="view_ids" eval="[(5, 0, 0),
(0, 0, {'view_mode': 'tree', 'view_id': ref('soong_workflow.soong_workflow_record_tree_restore')})]"/>
</record>
</data>
</odoo>
@@ -202,49 +202,72 @@ class SoongWorkflowCommentWizard(models.TransientModel):
('user_id', '=', button.reviewer_id.id),
], limit=1)
return employee
# 部门筛选条件
# 部门和公司筛选条件
department_domain = []
company_domain = []
if record_id:
# 申请人自动匹配逻辑
if is_automatic:
department_domain = ['|', ('department_id', '=', record_id.department_id.id), ('department_ids', 'in', record_id.department_id.id)]
elif is_automatic_company or is_automatic_group:
applicant_field = None
for field_name in ['user_id', 'users_id']:
if hasattr(record_id, field_name):
applicant_field = getattr(record_id, field_name)
if applicant_field:
break
if applicant_field and hasattr(applicant_field, 'company_id'):
if is_automatic_company:
company_departments = self.env['hr.department'].search([('company_id', '=', applicant_field.company_id.id)]).ids
department_domain = ['|', ('department_id', 'in', company_departments), ('department_ids', 'in', company_departments)]
elif is_automatic_group:
parent_company = applicant_field.company_id.parent_id
group_departments = self.env['hr.department'].search([('company_id', 'child_of', parent_company.id)]).ids if parent_company else []
department_domain = ['|', ('department_id', 'in', group_departments), ('department_ids', 'in', group_departments)]
# 登录人自动匹配逻辑
elif is_logged_by:
department_domain = ['|', ('department_id', '=', self.env.user.department_id.id), ('department_ids', 'in', self.env.user.department_id.id)]
# 获取当前用户和申请人的相关信息
current_user = self.env.user
applicant = None
# 尝试获取申请人的用户对象
for field_name in ['user_id', 'users_id']:
if hasattr(record_id, field_name):
applicant = getattr(record_id, field_name)
if applicant:
break
# 根据勾选的条件设置域条件(只勾选一个)
if is_automatic and record_id.department_id:
# 按当前申请人自动匹配-本部门(保留部门和公司条件)
department_domain = ['|', ('department_id', '=', record_id.department_id.id),
('department_ids', 'in', record_id.department_id.id)]
company_domain = [('company_id', '=', record_id.company_id.id)] if hasattr(record_id,
'company_id') else []
elif is_automatic_company and applicant and hasattr(applicant, 'company_id'):
# 按当前申请人自动匹配-本公司(仅保留公司条件)
company_id = applicant.company_id.id
company_domain = [('company_id', '=', company_id)]
elif is_automatic_group and applicant and hasattr(applicant, 'company_id'):
# 按当前申请人自动匹配-本集团(仅保留公司条件)
parent_company = applicant.company_id.parent_id
if parent_company:
group_company_ids = self.env['res.company'].search([('id', 'child_of', parent_company.id)]).ids
company_domain = [('company_id', 'in', group_company_ids)]
elif is_logged_by and current_user.department_id:
# 按当前登录人自动匹配-本部门(保留部门和公司条件)
department_domain = ['|', ('department_id', '=', current_user.department_id.id),
('department_ids', 'in', current_user.department_id.id)]
company_domain = [('company_id', '=', current_user.company_id.id)]
elif is_logged_company:
company_departments = self.env['hr.department'].search([('company_id', '=', self.env.user.company_id.id)]).ids
department_domain = ['|', ('department_id', 'in', company_departments), ('department_ids', 'in', company_departments)]
# 按当前登录人自动匹配-本公司(仅保留公司条件)
company_id = current_user.company_id.id
company_domain = [('company_id', '=', company_id)]
elif is_logged_group:
parent_company = self.env.user.company_id.parent_id
group_departments = self.env['hr.department'].search([('company_id', 'child_of', parent_company.id)]).ids if parent_company else []
department_domain = ['|',('department_id', 'in', group_departments),
('department_ids', 'in', group_departments)]
# 按当前登录人自动匹配-本集团(仅保留公司条件)
parent_company = current_user.company_id.parent_id
if parent_company:
group_company_ids = self.env['res.company'].search([('id', 'child_of', parent_company.id)]).ids
company_domain = [('company_id', 'in', group_company_ids)]
# 角色筛选
if link_users_id:
role_domain = ['|', ('user_role_id', '=', link_users_id.id), ('user_role_ids', 'in', link_users_id.id)]
company_domain = [('company_id', '=', self.env.user.company_id.id)]
domain = role_domain + company_domain + department_domain
return self.env['hr.employee'].sudo().search(domain)
elif link_users_group_ids:
role_domain = ['|', ('user_role_id', 'in', link_users_group_ids.user_role_ids.ids), ('user_role_ids', 'in', link_users_group_ids.user_role_ids.ids)]
company_domain = [('company_id', '=', self.env.user.company_id.id)]
role_domain = ['|', ('user_role_id', 'in', link_users_group_ids.user_role_ids.ids),
('user_role_ids', 'in', link_users_group_ids.user_role_ids.ids)]
domain = role_domain + company_domain + department_domain
return self.env['hr.employee'].sudo().search(domain)
# 特殊分发按钮
if '分发' in link.name and record_id and hasattr(record_id, 'users_id'):
return record_id.users_id.employee_id
@@ -13,7 +13,6 @@
<field name="department_id" column_invisible="1"/>
<field name="users_ids" column_invisible="1"/>
<field name="create_date1"/>
<field name="start_date"/>
<field name="end_date"/>
<field name="notice_state" class="list_ids_width"/>
<button name="on_sequence" string="置顶" invisible="sequence != 0" type="object" class="btn-primary"/>
@@ -47,9 +46,6 @@
<group>
<field name="is_this_company"/>
</group>
<group>
<field name="start_date"/>
</group>
</group>
<div class="col-12 text-center">
<h1>
@@ -68,7 +64,6 @@
<field name="work_end" invisible="1"/>
<field name="department_id" string="发布部门" invisible="1"/>
<field name="create_date1"/>
<field name="start_date"/>
</group>
</group>
<group>
@@ -128,7 +123,6 @@
<field name="department_id" column_invisible="1"/>
<field name="users_ids" column_invisible="1"/>
<field name="create_date1"/>
<field name="start_date"/>
<field name="end_date" column_invisible="1"/>
</tree>
</field>
@@ -152,9 +146,6 @@
<group>
<field name="create_date1"/>
</group>
<group>
<field name="start_date"/>
</group>
</group>
<div class="col-12 text-center">
<h1>
@@ -52,7 +52,7 @@ class PropertyLeaseContract(models.Model):
rent_company = fields.Char(related='company_id.name', string="收租公司名称")
rent_account = fields.Char(related='company_id.rent_account', string="收租公司账号")
users_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user.id)
department_id = fields.Many2one(related='users_id.employee_id.department_id', string="部门")
department_id = fields.Many2one(related='users_id.employee_id.department_id', string="部门", store=True)
# 承租方的个人信息
lessee_id = fields.Many2one('property.tenant.information', string='承租方')
lessee_name = fields.Char(related='lessee_id.name', string="承租方姓名")