!10271 !10270 Merge branch 'master' into dev_zhou

Merge pull request !10271 from 李鹏宇/dev
This commit is contained in:
李鹏宇
2026-03-26 04:05:51 +00:00
committed by Gitee
2 changed files with 96 additions and 79 deletions
+95 -79
View File
@@ -576,24 +576,20 @@ class IssueLibrary(models.Model):
self.write({"issue_state": "cancel"})
def all_meeting_issue(self):
issue_active_ids = self.env["issue.library"].browse(self._context.get('active_ids', self._context.get('active_id', [])))
issue_active_ids = self.env["issue.library"].browse(
self._context.get('active_ids', self._context.get('active_id', [])))
current_user = self.env.user
user_company_name = current_user.company_id.name if current_user.company_id else ""
action_id = self._context.get('from_action')
for ras in issue_active_ids:
# if action_id == 'issue_library_action3' and ras.issue_state_party != 'will':
# raise UserError(f"议题为{ras.name}不可上会",)
# elif action_id == 'issue_library_action4' and ras.issue_state_class != 'will':
# raise UserError(f"议题为{ras.name}不可上会",)
# elif action_id == 'issue_library_action5' and ras.issue_state_boss != 'will':
# raise UserError(f"议题为{ras.name}不可上会",)
issue_details = []
target_meeting_type_id = False
meeting_priority = [
('is_party', 'is_party_passed', None), # 党总支:动态匹配名称(集团本部=党总支/其他=党支委)
('is_class', 'is_class_passed', '班子'), # 班子会:匹配含「班子」的名称
('is_boss', 'is_boss_passed', '董事'), # 董事会:匹配含「董事」的名称
('is_party', 'is_party_passed', None),
('is_class', 'is_class_passed', '班子'),
('is_boss', 'is_boss_passed', '董事'),
]
def get_all_sub_departments(department):
dept_ids = [department.id]
sub_depts = self.env['hr.department'].search([('parent_id', '=', department.id)])
@@ -606,6 +602,58 @@ class IssueLibrary(models.Model):
('department_id', 'in', all_dept_ids),
('active', '=', True)
])
# 先匹配出最终会议类型(原有逻辑)
for issue in issue_active_ids:
if target_meeting_type_id:
continue
# 按「党→班子→董事」优先级匹配
for idx, (field_flag, field_passed, keyword) in enumerate(meeting_priority):
if not getattr(issue, field_flag, False):
continue
passed_result = getattr(issue, field_passed, '')
if passed_result in (False, 'reject'):
if idx == 0:
party_meeting_name = "党总支" if user_company_name == "集团本部" else "党支委"
meeting_type = self.env['room.meeting.type'].search([('name', 'ilike', party_meeting_name)],
limit=1)
else:
meeting_type = self.env['room.meeting.type'].search([('name', 'ilike', keyword)], limit=1)
if meeting_type:
target_meeting_type_id = meeting_type.id
break
elif passed_result == 'pass':
continue
# 天河粮储 套会逻辑
if len(issue_active_ids) == 2 and all(ras.company_id.name == "天河粮储" for ras in issue_active_ids):
record_a, record_b = issue_active_ids
condition = ((getattr(record_a, 'is_party', False) and not getattr(record_b, 'is_party',
False) and getattr(record_b,
'is_class',
False))
or (getattr(record_b, 'is_party', False) and not getattr(record_a, 'is_party',
False) and getattr(record_a,
'is_class',
False)))
all_char_empty = (
not getattr(record_a, 'party_char', '') and not getattr(record_a, 'class_char', '')
and not getattr(record_b, 'party_char', '') and not getattr(record_b, 'class_char', ''))
if condition and all_char_empty:
meeting_type_with_tao = self.env['room.meeting.type'].search([('name', 'ilike', '套')], limit=1)
if meeting_type_with_tao:
target_meeting_type_id = meeting_type_with_tao.id
# ====================== 核心新增:判断会议名称是否含「党」 ======================
meeting_type_has_dang = False
if target_meeting_type_id:
meeting_type = self.env['room.meeting.type'].browse(target_meeting_type_id)
# 判断会议类型名称是否包含 "党" 字
if meeting_type.name and '党' in meeting_type.name:
meeting_type_has_dang = True
# 生成议题明细,根据是否含党字设置 is_sanda
for issue in issue_active_ids:
dept_manager = self.env['hr.employee'].search([
('active', '=', True),
@@ -614,73 +662,29 @@ class IssueLibrary(models.Model):
('department_id', '=', issue.department_id.id),
('department_ids', 'in', [issue.department_id.id])
], limit=1)
# 关键:会议名称含党 → is_sanda=True,否则 False
issue_details.append((0, 0, {
'issue_library_id': issue.id,
'employee_id': dept_manager.id if dept_manager else False,
'designated_person_ids': [(6, 0, target_employees.ids)],
'is_sanda': meeting_type_has_dang, # 自动赋值
}))
if target_meeting_type_id:
continue
# 按「党→班子→董事」优先级匹配
for idx, (field_flag, field_passed, keyword) in enumerate(meeting_priority):
# 跳过未勾选的会议类型
if not getattr(issue, field_flag, False):
continue
passed_result = getattr(issue, field_passed, '')
# 逻辑:空/未通过 → 匹配对应会议类型;已通过 → 继续匹配下一级
if passed_result in (False, 'reject'):
if idx == 0:
if user_company_name == "集团本部":
party_meeting_name = "党总支"
else:
party_meeting_name = "党支委"
meeting_type = self.env['room.meeting.type'].search([
('name', 'ilike', party_meeting_name)
], limit=1)
else:
meeting_type = self.env['room.meeting.type'].search([
('name', 'ilike', keyword)
], limit=1)
if meeting_type:
target_meeting_type_id = meeting_type.id
break
elif passed_result == 'pass':
continue
if len(issue_active_ids) == 2 and all(ras.company_id.name == "天河粮储" for ras in issue_active_ids):
record_a, record_b = issue_active_ids
# 定义核心判断条件:
# 场景1:A党勾 + B党未勾且班子勾 OR 场景2:B党勾 + A党未勾且班子勾
condition = ((getattr(record_a, 'is_party', False) and not getattr(record_b, 'is_party', False) and getattr(record_b, 'is_class', False))
or
(getattr(record_b, 'is_party', False) and not getattr(record_a, 'is_party',False) and getattr(record_a,'is_class', False)))
all_char_empty = (
not getattr(record_a, 'party_char', '') and not getattr(record_a, 'class_char', '')
and
not getattr(record_b, 'party_char', '') and not getattr(record_b, 'class_char', '')
)
if condition and all_char_empty:
meeting_type_with_tao = self.env['room.meeting.type'].search([
('name', 'ilike', '套')# 模糊匹配含「套」的会议类型
], limit=1)
if meeting_type_with_tao:
target_meeting_type_id = meeting_type_with_tao.id
form_id = self.env.ref("room.room_booking_view_form", raise_if_not_found=False)
return {
"type": "ir.actions.act_window",
"name": "批量上会",
"res_model": "room.booking",
"views": [[form_id.id, "form"]],
"context": {
'default_is_issue': True,
'default_state': '申请人',
'default_meeting_type_id': target_meeting_type_id,
'default_start_datetime': fields.Datetime.now() + timedelta(hours=8),
'default_issue_meeting_line_ids': issue_details,
}
}
form_id = self.env.ref("room.room_booking_view_form", raise_if_not_found=False)
return {
"type": "ir.actions.act_window",
"name": "批量上会",
"res_model": "room.booking",
"views": [[form_id.id, "form"]],
"context": {
'default_is_issue': True,
'default_state': '申请人',
'default_meeting_type_id': target_meeting_type_id,
'default_start_datetime': fields.Datetime.now() + timedelta(hours=8),
'default_issue_meeting_line_ids': issue_details,
},
}
def single_meeting_issue(self):
issue = self.env["issue.library"].browse(self.id)
@@ -693,12 +697,14 @@ class IssueLibrary(models.Model):
('is_class', 'is_class_passed', '班子'), # 班子会:匹配含「班子」的名称
('is_boss', 'is_boss_passed', '董事'), # 董事会:匹配含「董事」的名称
]
def get_all_sub_departments(department):
dept_ids = [department.id]
sub_depts = self.env['hr.department'].search([('parent_id', '=', department.id)])
for sub_dept in sub_depts:
dept_ids += get_all_sub_departments(sub_dept)
return dept_ids
all_dept_ids = get_all_sub_departments(self.department_id)
target_employees = self.env['hr.employee'].search([
('department_id', 'in', all_dept_ids),
@@ -722,23 +728,17 @@ class IssueLibrary(models.Model):
attendees_ids = target_managers.filtered(lambda emp: emp.id != manager_employee.id).ids
elif target_managers:
attendees_ids = target_managers.id
# 先匹配会议类型
for issue in self:
issue_details.append((0, 0, {
'issue_library_id': issue.id,
'employee_id': manager_employee.id,
'designated_person_ids': [(6, 0, target_employees.ids)],
'attendees_ids': [(6, 0, attendees_ids)],
}))
if target_meeting_type_id:
continue
# 按「党→班子→董事」优先级匹配
for idx, (field_flag, field_passed, keyword) in enumerate(meeting_priority):
# 跳过未勾选的会议类型
if not getattr(issue, field_flag, False):
continue
passed_result = getattr(issue, field_passed, '')
# 逻辑:空/未通过 → 匹配对应会议类型;已通过 → 继续匹配下一级
if passed_result in (False, 'reject'):
if idx == 0:
if user_company_name == "集团本部":
@@ -757,6 +757,22 @@ class IssueLibrary(models.Model):
break
elif passed_result == 'pass':
continue
meeting_type_has_dang = False
if target_meeting_type_id:
meeting_type = self.env['room.meeting.type'].browse(target_meeting_type_id)
if meeting_type.name and '党' in meeting_type.name:
meeting_type_has_dang = True
for issue in self:
issue_details.append((0, 0, {
'issue_library_id': issue.id,
'employee_id': manager_employee.id if manager_employee else False,
'designated_person_ids': [(6, 0, target_employees.ids)],
'attendees_ids': [(6, 0, attendees_ids)],
'is_sanda': meeting_type_has_dang,
}))
form_id = self.env.ref("room.room_booking_view_form").id
return {
"type": "ir.actions.act_window",
@@ -23,6 +23,7 @@
<field name="issue_meeting_line_ids">
<tree editable="bottom">
<button name="open_record" type="object" string="详情" class="oe_highlight"/>
<field name="sequence" widget="handle"/>
<field name="meeting_booking_id" column_invisible="1"/>
<field name="issue_library_id"/>
<field name="employee_id" options="{'no_create': True}" domain="[('id', 'in', designated_person_ids)]"/>