添加功能
This commit is contained in:
@@ -708,17 +708,13 @@ class IssueLibrary(models.Model):
|
||||
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')
|
||||
|
||||
issue_details = []
|
||||
target_meeting_type_id = False
|
||||
|
||||
for ras in issue_active_ids:
|
||||
# 会议优先级:党 → 班子 → 董事
|
||||
# 每个元组:(is_xxx字段, 对应的char字段, 会议关键字, 是否已上会)
|
||||
issue_details = []
|
||||
target_meeting_type_id = False
|
||||
meeting_priority = [
|
||||
('is_party', 'party_char', '党'),
|
||||
('is_class', 'class_char', '班子'),
|
||||
('is_boss', 'boss_char', '董事'),
|
||||
('is_party', 'is_party_passed', None),
|
||||
('is_class', 'is_class_passed', '班子'),
|
||||
('is_boss', 'is_boss_passed', '董事'),
|
||||
]
|
||||
|
||||
def get_all_sub_departments(department):
|
||||
@@ -734,83 +730,70 @@ class IssueLibrary(models.Model):
|
||||
('active', '=', True)
|
||||
])
|
||||
|
||||
# 匹配出最终会议类型
|
||||
# 先匹配出最终会议类型(原有逻辑)
|
||||
for issue in issue_active_ids:
|
||||
if target_meeting_type_id:
|
||||
continue
|
||||
|
||||
for idx, (field_flag, char_field, keyword) in enumerate(meeting_priority):
|
||||
# 按「党→班子→董事」优先级匹配
|
||||
for idx, (field_flag, field_passed, keyword) in enumerate(meeting_priority):
|
||||
if not getattr(issue, field_flag, False):
|
||||
continue
|
||||
|
||||
# 获取对应的 char 字段值
|
||||
char_value = getattr(issue, char_field, '') or ''
|
||||
# 去除 HTML 标签后判断是否有值
|
||||
clean_char = re.sub(r'<[^>]+>', '', char_value).strip()
|
||||
|
||||
# ✅ 只要有值,就代表已上会通过
|
||||
if clean_char:
|
||||
# 特殊校验:班子上会,必须先有党的意见
|
||||
if keyword == '班子' and ras.is_party == True:
|
||||
party_value = getattr(issue, 'party_char', '') or ''
|
||||
clean_party = re.sub(r'<[^>]+>', '', party_value).strip()
|
||||
passed_result = getattr(issue, field_passed, '')
|
||||
if passed_result in (False, 'reject'):
|
||||
# 班子上会:党的 party_char 不能为空
|
||||
if idx == 1 and ras.is_party == True:
|
||||
clean_party = re.sub(r'<[^>]+>', '', issue.party_char or '').strip()
|
||||
if not clean_party:
|
||||
raise UserError("党的意见为空,不能上班子会")
|
||||
|
||||
# 特殊校验:董事上会,必须先有党的意见和班子意见
|
||||
if keyword == '董事' and ras.is_party == True and ras.is_class == True:
|
||||
party_value = getattr(issue, 'party_char', '') or ''
|
||||
clean_party = re.sub(r'<[^>]+>', '', party_value).strip()
|
||||
class_value = getattr(issue, 'class_char', '') or ''
|
||||
clean_class = re.sub(r'<[^>]+>', '', class_value).strip()
|
||||
# 董事上会:党的 party_char 和班子的 class_char 都不能为空
|
||||
elif idx == 2 and ras.is_party == True and ras.is_class == True:
|
||||
clean_party = re.sub(r'<[^>]+>', '', issue.party_char or '').strip()
|
||||
clean_class = re.sub(r'<[^>]+>', '', issue.class_char or '').strip()
|
||||
if not clean_party:
|
||||
raise UserError("党的意见为空,不能上董事会")
|
||||
if not clean_class:
|
||||
raise UserError("班子意见为空,不能上董事会")
|
||||
|
||||
# 查找对应的会议类型
|
||||
if keyword == '党':
|
||||
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
|
||||
)
|
||||
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
|
||||
)
|
||||
|
||||
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
|
||||
# 天河粮储 套会逻辑
|
||||
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'].sudo().search([
|
||||
('active', '=', True),
|
||||
@@ -822,11 +805,12 @@ class IssueLibrary(models.Model):
|
||||
('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,
|
||||
'is_sanda': meeting_type_has_dang, # 自动赋值
|
||||
}))
|
||||
|
||||
form_id = self.env.ref("room.room_booking_view_form", raise_if_not_found=False)
|
||||
|
||||
Reference in New Issue
Block a user