680 lines
31 KiB
Python
680 lines
31 KiB
Python
# -*- coding: utf-8 -*-
|
|
from odoo import api, fields, models, tools
|
|
from odoo.exceptions import UserError, ValidationError
|
|
from datetime import datetime, timedelta, date
|
|
|
|
|
|
class IssueLibrary(models.Model):
|
|
_name = "issue.library"
|
|
_description = '议题总库'
|
|
_inherit = ['mail.thread.main.attachment', 'mail.activity.mixin']
|
|
_rec_name = 'name'
|
|
|
|
name = fields.Char(string='议题名称')
|
|
name_text = fields.Text(string='议题名称', compute='_compute_name', readonly=False)
|
|
depart_opinions = fields.Text(string='部门意见')
|
|
topic_content = fields.Text(string='事项背景')
|
|
will_based = fields.Text(string='上会依据', compute='_compute_will_based', readonly=False)
|
|
deliberation_content = fields.Text(string='请示事项', default='建议同意')
|
|
handling_situation = fields.Text(string='办理情况', help="(存在问题)")
|
|
is_invisible_workflow = fields.Boolean(string="流程隐藏的判断")
|
|
code = fields.Char(string='编号', required=True, copy=False,
|
|
default=lambda self: self.env['ir.sequence'].next_by_code('issue_library_code'))
|
|
issue_state = fields.Selection([('draft', '待申报'), ('to_approval', '待审批'), ('approval', '审批中'), ('on_approval', '已审批'),
|
|
('will', '待上会'), ('on_meet', '已上会'), ('cancel', '已取消')],
|
|
default='draft', string="议题状态")
|
|
is_party = fields.Boolean(string="党总支", store=True)
|
|
party_char = fields.Char(string=' ')
|
|
is_class = fields.Boolean(string="班子会", store=True)
|
|
class_char = fields.Char(string=' ')
|
|
is_boss = fields.Boolean(string="董事会", store=True)
|
|
boss_char = fields.Char(string=' ')
|
|
is_note = fields.Boolean(string="上级单位", compute='_compute_issue_library_line_ids', store=True)
|
|
is_district_state = fields.Boolean(string="区国资局", compute='_compute_issue_library_line_ids', store=True)
|
|
is_district_government = fields.Boolean(string="区政府", compute='_compute_issue_library_line_ids', store=True)
|
|
is_district_party = fields.Boolean(string="区委组织部", compute='_compute_issue_library_line_ids', store=True)
|
|
creart_datetime = fields.Date(string="创建日期", default=fields.Datetime.now)
|
|
documents_ids = fields.Many2many('ir.attachment', string='议题附件')
|
|
issue_type_id = fields.Many2one('issue.type', string="议题类型")
|
|
relevancy_type = fields.Selection([('none', '无')], string="关联流程类型")
|
|
issue_approval_id = fields.Many2one('issue.approval', string="关联议题审批")
|
|
issue_library_line_ids = fields.One2many('issue.library.line', 'issue_library_id', string="决策明细")
|
|
issue_library_approval_line_ids = fields.One2many('issue.library.approval.line', 'issue_library_id', string='流程记录')
|
|
approval_decision_sequence = fields.Char(string="决策清单事项")
|
|
is_booking = fields.Boolean(string="是否上会")
|
|
issues_result = fields.Html(string="会议结果")
|
|
cs_party = fields.Char(string='党支委')
|
|
cs_class = fields.Char(string='班子会')
|
|
cs_boss = fields.Char(string='董事会')
|
|
issue_library_room_line_ids = fields.One2many('issue.library.room.line', 'issue_library_id', string="关联会议明细行")
|
|
# 权限相关隐藏字段
|
|
employee_id = fields.Many2one('hr.employee', string='创建人', default=lambda self: self.env.user.employee_id)
|
|
department_id = fields.Many2one('hr.department', string='部门', related='employee_id.department_id')
|
|
users_role_ids = fields.Many2many('soong.user.role', string='角色范围', related='employee_id.user_role_ids')
|
|
company_id = fields.Many2one('res.company', string='公司', related='employee_id.company_id', store=True)
|
|
is_legal_trial = fields.Selection([('no', '否'), ('yes', '是')], string="是否法审", default='no')
|
|
workflow_id = fields.Many2one('soong.workflow.record', string="流程")
|
|
department_personnel_ids = fields.Many2many('res.users', string='部门人员')
|
|
approval_name = fields.Char(string="审批标题")
|
|
meeting_place = fields.Char(string="会议地点")
|
|
meeting_name = fields.Char(string="会议名称")
|
|
active = fields.Boolean('Active', default=True, tracking=True)
|
|
urgency_level = fields.Selection([('normal', '普件'), ('urgent', '急件'), ('emergency', '特急件')], string='紧急度',
|
|
default='normal')
|
|
work_end = fields.Boolean(string="结束")
|
|
member_of_department = fields.Boolean("是否是本部门数据", compute='_compute_part_of_department',
|
|
search='_search_part_of_department')
|
|
|
|
is_party_passed = fields.Selection([('',''), ('pass', '通过'), ('reject', '未通过')])
|
|
is_class_passed = fields.Selection([('',''), ('pass', '通过'), ('reject', '未通过')])
|
|
is_boss_passed = fields.Selection([('',''), ('pass', '通过'), ('reject', '未通过')])
|
|
push_invisible = fields.Boolean(string="推送隐藏", compute='_compute_push_invisible')
|
|
|
|
is_push_party = fields.Boolean(string="党推送")
|
|
is_push_class = fields.Boolean(string="班子推送")
|
|
is_push_boss = fields.Boolean(string="董事推送")
|
|
is_push_depart = fields.Boolean(string="部门推送")
|
|
|
|
is_state_updated = fields.Boolean(string='状态是否已更新', default=False)
|
|
|
|
def issue_party_approval(self):
|
|
issue_active_ids = self.env["issue.library"].browse(
|
|
self._context.get('active_ids', self._context.get('active_id'))
|
|
)
|
|
line_list = []
|
|
for record in issue_active_ids:
|
|
if record.issue_state != 'to_approval':
|
|
raise UserError("该议题状态不能审批")
|
|
record.issue_state = 'approval'
|
|
line_list.append((0, 0, {
|
|
'issue_id': record.id,
|
|
'name': record.name,
|
|
'will_based': record.will_based,
|
|
'department_id': record.department_id.id,
|
|
}))
|
|
return {
|
|
'type': 'ir.actions.act_window',
|
|
'name': '党议题审批',
|
|
"target": "current",
|
|
'res_model': 'issue.party.approval',
|
|
'view_mode': 'form',
|
|
'context': {
|
|
'default_state':'申请人',
|
|
'default_name_title': '党总支议题审批',
|
|
'default_line_ids': line_list,
|
|
}
|
|
}
|
|
|
|
def issue_party1_approval(self):
|
|
issue_active_ids = self.env["issue.library"].browse(
|
|
self._context.get('active_ids', self._context.get('active_id'))
|
|
)
|
|
line_list = []
|
|
for record in issue_active_ids:
|
|
if record.issue_state != 'to_approval':
|
|
raise UserError("该议题状态不能审批")
|
|
record.issue_state = 'approval'
|
|
line_list.append((0, 0, {
|
|
'issue_id': record.id,
|
|
'name': record.name,
|
|
'will_based': record.will_based,
|
|
'department_id': record.department_id.id,
|
|
}))
|
|
return {
|
|
'type': 'ir.actions.act_window',
|
|
'name': '党议题审批',
|
|
"target": "current",
|
|
'res_model': 'issue.party.approval',
|
|
'view_mode': 'form',
|
|
'context': {
|
|
'default_state':'申请人',
|
|
'default_name_title': '党支部议题审批',
|
|
'default_line_ids': line_list,
|
|
}
|
|
}
|
|
|
|
def issue_class_approval(self):
|
|
issue_active_ids = self.env["issue.library"].browse(
|
|
self._context.get('active_ids', self._context.get('active_id'))
|
|
)
|
|
line_list = []
|
|
for record in issue_active_ids:
|
|
if record.issue_state != 'to_approval':
|
|
raise UserError("该议题状态不能审批")
|
|
record.issue_state = 'approval'
|
|
line_list.append((0, 0, {
|
|
'issue_id': record.id,
|
|
'name': record.name,
|
|
'will_based': record.will_based,
|
|
'department_id': record.department_id.id,
|
|
}))
|
|
return {
|
|
'type': 'ir.actions.act_window',
|
|
'name': '班子议题审批',
|
|
"target": "current",
|
|
'res_model': 'issue.class.approval',
|
|
'view_mode': 'form',
|
|
'context': {
|
|
'default_state': '申请人',
|
|
'default_line_ids': line_list,
|
|
}
|
|
}
|
|
|
|
def issue_boss_approval(self):
|
|
issue_active_ids = self.env["issue.library"].browse(
|
|
self._context.get('active_ids', self._context.get('active_id'))
|
|
)
|
|
line_list = []
|
|
for record in issue_active_ids:
|
|
if record.issue_state != 'to_approval':
|
|
raise UserError("该议题状态不能审批")
|
|
record.issue_state = 'approval'
|
|
line_list.append((0, 0, {
|
|
'issue_id': record.id,
|
|
'name': record.name,
|
|
'will_based': record.will_based,
|
|
'department_id': record.department_id.id,
|
|
}))
|
|
return {
|
|
'type': 'ir.actions.act_window',
|
|
'name': '董事议题审批',
|
|
"target": "current",
|
|
'res_model': 'issue.boss.approval',
|
|
'view_mode': 'form',
|
|
'context': {
|
|
'default_state': '申请人',
|
|
'default_line_ids': line_list,
|
|
}
|
|
}
|
|
|
|
@api.depends(
|
|
'is_party', 'is_class', 'is_boss',
|
|
'is_push_party', 'is_party_passed',
|
|
'is_push_class', 'is_class_passed',
|
|
'is_push_boss', 'is_boss_passed',
|
|
'is_push_depart'
|
|
)
|
|
def _compute_push_invisible(self):
|
|
for record in self:
|
|
record.push_invisible = False
|
|
type_mapping = {
|
|
'party': (record.is_party, record.is_party_passed),
|
|
'class': (record.is_class, record.is_class_passed),
|
|
'boss': (record.is_boss, record.is_boss_passed),
|
|
}
|
|
# 筛选开关为True的类型,收集其passed值
|
|
active_passed_values = []
|
|
for type_key, (type_switch, type_passed) in type_mapping.items():
|
|
if type_switch:
|
|
active_passed_values.append(type_passed)
|
|
# 所有激活类型的passed都为pass → 设为True
|
|
if active_passed_values and all(passed == 'pass' for passed in active_passed_values):
|
|
record.push_invisible = True
|
|
continue
|
|
|
|
if record.is_party:
|
|
if not record.is_push_party and (record.is_party_passed == 'reject' or not record.is_party_passed):
|
|
record.push_invisible = True
|
|
continue
|
|
if record.is_class:
|
|
if not record.is_push_class and (record.is_class_passed == 'reject' or not record.is_class_passed):
|
|
record.push_invisible = True
|
|
continue
|
|
if record.is_boss:
|
|
if not record.is_push_boss and (record.is_boss_passed == 'reject' or not record.is_boss_passed):
|
|
record.push_invisible = True
|
|
continue
|
|
|
|
if record.issue_state in ['will', 'on_meet']:
|
|
if record.push_invisible :
|
|
record.issue_state = 'on_meet'
|
|
else:
|
|
record.issue_state = 'will'
|
|
|
|
|
|
@api.depends('issue_library_line_ids',
|
|
'issue_library_line_ids.issue_approval_decision_id',
|
|
'issue_library_line_ids.district_state_id',
|
|
'issue_library_line_ids.district_government_id',
|
|
'issue_library_line_ids.district_party_id')
|
|
def _compute_will_based(self):
|
|
for record in self:
|
|
will_based_lines = []
|
|
for idx, line in enumerate(record.issue_library_line_ids, start=1):
|
|
decision_name = line.issue_approval_decision_id.specifics or ""
|
|
district_state_name = line.district_state_id.name or ""
|
|
district_government_name = line.district_government_id.name or ""
|
|
district_party_name = line.district_party_id.name or ""
|
|
field_parts = []
|
|
if decision_name:
|
|
field_parts.append(decision_name)
|
|
if district_state_name:
|
|
field_parts.append(f"区国资局({district_state_name})")
|
|
if district_government_name:
|
|
field_parts.append(f"区政府({district_government_name})")
|
|
if district_party_name:
|
|
field_parts.append(f"区委组织部({district_party_name})")
|
|
if field_parts:
|
|
line_content = f"{idx}.{','.join(field_parts)}"
|
|
will_based_lines.append(line_content)
|
|
|
|
record.will_based = "\n".join(will_based_lines)
|
|
|
|
def correction(self):
|
|
for rec in self:
|
|
menu_id = self.env['ir.ui.menu'].search([('name', '=', '我的议题')])
|
|
url = f'https://oa.thtzjt.com/web#id={self.id}&cids=2&action={menu_id.action.id}&model=yuthon.notice&view_type=list&menu_id={menu_id.id}'
|
|
self.sudo().env["wecom.apps"].sync_send_message_textcard(category='oa',
|
|
user_id=rec.employee_id.wecom_userid,
|
|
title="议题修正",
|
|
description="您有待修正的议题,请尽快修正",
|
|
url=url, btntxt="详细信息")
|
|
return {
|
|
'type': 'ir.actions.client',
|
|
'tag': 'display_notification',
|
|
'params': {
|
|
'type': 'success',
|
|
'message': '已发送提醒消息',
|
|
'sticky': False,
|
|
}
|
|
}
|
|
|
|
def depart_push(self):
|
|
for rec in self:
|
|
rec.is_push_depart = True
|
|
|
|
def library_push(self):
|
|
for rec in self:
|
|
push_update_vals = {}
|
|
if rec.is_party and (rec.is_party_passed == 'reject' or not rec.is_party_passed):
|
|
push_update_vals['is_push_party'] = True
|
|
|
|
elif rec.is_class and (rec.is_class_passed == 'reject' or not rec.is_class_passed):
|
|
push_update_vals['is_push_class'] = True
|
|
|
|
elif rec.is_boss and (rec.is_boss_passed == 'reject' or not rec.is_boss_passed):
|
|
push_update_vals['is_push_boss'] = True
|
|
|
|
if push_update_vals:
|
|
rec.write(push_update_vals)
|
|
if not rec.is_state_updated:
|
|
rec.write({
|
|
'issue_state': 'to_approval',
|
|
})
|
|
else:
|
|
rec.write({
|
|
'issue_state': 'will'}
|
|
)
|
|
|
|
|
|
@api.onchange('is_legal_trial')
|
|
def _onchange_is_legal_trial(self):
|
|
self.department_personnel_ids = [(5, 0, 0)]
|
|
if self.is_legal_trial:
|
|
if self.department_id:
|
|
target_department_ids = self.env['hr.department'].search([
|
|
('id', 'child_of', self.department_id.id)
|
|
]).ids
|
|
target_employees = self.env['hr.employee'].search([
|
|
('department_id', 'in', target_department_ids),
|
|
('user_state', '=', 'in')
|
|
])
|
|
self.department_personnel_ids = [(6, 0, target_employees.user_id.ids)]
|
|
else:
|
|
self.department_personnel_ids = [(5, 0, 0)]
|
|
|
|
def add_workflow(self):
|
|
return {
|
|
'name': '流程添加弹窗',
|
|
'type': 'ir.actions.act_window',
|
|
'view_mode': 'form',
|
|
'res_model': 'issue.line.add.wizard',
|
|
"target": "new",
|
|
'context': {
|
|
'default_issue_id': self.id,
|
|
},
|
|
}
|
|
|
|
@api.depends_context('uid', 'company')
|
|
@api.depends('department_id')
|
|
def _compute_part_of_department(self):
|
|
user_employee = self._get_valid_employee_for_user()
|
|
active_department = user_employee.department_id
|
|
if active_department:
|
|
department_ids = self.env['hr.department'].search([
|
|
('id', 'child_of', active_department.id)
|
|
]).ids
|
|
else:
|
|
department_ids = []
|
|
for employee in self:
|
|
employee.member_of_department = employee.department_id.id in department_ids
|
|
|
|
def _get_valid_employee_for_user(self):
|
|
user = self.env.user
|
|
employee = user.employee_ids
|
|
if not employee:
|
|
user_employees = user.employee_id.sudo().search([
|
|
('user_id', '=', user.id)
|
|
])
|
|
employee = user_employees.filtered(lambda r: r.company_id == user.company_id) or user_employees[:1]
|
|
return employee
|
|
|
|
def _search_part_of_department(self, operator, value):
|
|
user_employee = self._get_valid_employee_for_user()
|
|
active_department = user_employee.department_id
|
|
if active_department:
|
|
base_domain = [('department_id', 'child_of', active_department.id)]
|
|
else:
|
|
base_domain = [('department_id', '=', False)]
|
|
return (['!'] if operator == '!=' else []) + base_domain
|
|
|
|
def _get_default_name_title(self):
|
|
return self._description if self._description else self._name
|
|
|
|
name_title = fields.Char(default=_get_default_name_title)
|
|
|
|
def read_number(self):
|
|
return self.search_count([
|
|
('issue_state', '=', 'draft'),
|
|
('employee_id.user_id', '=', self.env.user.id)
|
|
])
|
|
|
|
@api.onchange('issue_library_line_ids')
|
|
def onchange_approval_decision_sequence(self):
|
|
for dec in self:
|
|
specifics_list = []
|
|
for line in dec.issue_library_line_ids:
|
|
if line.issue_approval_decision_id:
|
|
specifics_list.append(line.issue_approval_decision_id.specifics)
|
|
dec.approval_decision_sequence = ';'.join(specifics_list) if specifics_list else ''
|
|
|
|
def revoke(self):
|
|
self.write({'issue_state': 'draft'})
|
|
if self.issue_approval_id:
|
|
issue_line_records = self.env['issue.approval.line'].search([
|
|
('issue_approval_id', '=', self.issue_approval_id.id)
|
|
])
|
|
if issue_line_records:
|
|
issue_line_records.unlink()
|
|
workflow_id = self.env['soong.workflow.record'].search([('res_model', '=', 'issue.approval'),
|
|
('res_id', '=', self.issue_approval_id.id)], limit=1)
|
|
if workflow_id:
|
|
workflow_id.sudo().unlink()
|
|
self.issue_approval_id.unlink()
|
|
|
|
def all_issue_pull(self):
|
|
issue_active_ids = self.env["issue.library"].browse(
|
|
self._context.get('active_ids', self._context.get('active_id'))
|
|
)
|
|
for i in issue_active_ids:
|
|
if i.issue_state not in ['draft', 'approval']:
|
|
raise UserError("当前状态不允许提交")
|
|
|
|
existing_approval = self.env['issue.approval'].search([
|
|
('issue_approval_ids.issue_library_id', 'in', issue_active_ids.ids),
|
|
], limit=1)
|
|
|
|
specifics_list = [rec.name for rec in issue_active_ids]
|
|
name = ','.join(specifics_list) if len(specifics_list) > 1 else (
|
|
self.name or specifics_list[0] if specifics_list else "")
|
|
|
|
if existing_approval:
|
|
issue_approval_id = existing_approval
|
|
else:
|
|
issue_decision_lines = []
|
|
for issue_record in issue_active_ids:
|
|
issue_record.write({"issue_state": "approval"})
|
|
issue_decision_lines.append((0, 0, {
|
|
'issue_library_id': issue_record.id,
|
|
'approval_decision_sequence': issue_record.approval_decision_sequence,
|
|
'is_party': issue_record.is_party,
|
|
'is_class': issue_record.is_class,
|
|
'is_boss': issue_record.is_boss,
|
|
'is_note': issue_record.is_note,
|
|
'employee_id': issue_record.employee_id.id
|
|
}))
|
|
|
|
issue_approval_id = self.env['issue.approval'].create({
|
|
'issue_approval_ids': issue_decision_lines,
|
|
'name': name,
|
|
})
|
|
self.issue_approval_id = issue_approval_id
|
|
|
|
form_id = self.env.ref("yuthon_issue.issue_library_approval_form").id
|
|
return {
|
|
"type": "ir.actions.act_window",
|
|
"name": "提交议题审批",
|
|
"res_model": "issue.approval",
|
|
"views": [[form_id, "form"]],
|
|
"res_id": issue_approval_id.id,
|
|
"context": {
|
|
"id": issue_approval_id.id,
|
|
"is_issue": True,
|
|
}
|
|
}
|
|
|
|
def single_issue_pull(self):
|
|
if self.issue_state != 'draft':
|
|
raise UserError("当前状态不允许提交")
|
|
|
|
form_id = self.env.ref("yuthon_issue.issue_library_approval_form").id
|
|
issue_decision_lines = [(0, 0, {
|
|
'issue_library_id': self.id,
|
|
'approval_decision_sequence': self.approval_decision_sequence,
|
|
'is_party': self.is_party,
|
|
'is_class': self.is_class,
|
|
'is_boss': self.is_boss,
|
|
'is_note': self.is_note,
|
|
'employee_id': self.employee_id.id
|
|
})]
|
|
|
|
issue_approval_id = self.env['issue.approval'].create({
|
|
'issue_approval_ids': issue_decision_lines,
|
|
'name': self.name,
|
|
'employee_id': self.employee_id.id,
|
|
})
|
|
self.write({"issue_state": "approval"})
|
|
self.issue_approval_id = issue_approval_id
|
|
return {
|
|
"type": "ir.actions.act_window",
|
|
"name": "提交审批",
|
|
"res_model": "issue.approval",
|
|
"views": [[form_id, "form"]],
|
|
"res_id": issue_approval_id.id,
|
|
"context": {
|
|
"id": issue_approval_id.id,
|
|
"is_issue": True,
|
|
}
|
|
}
|
|
|
|
def issue_cancel(self):
|
|
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')))
|
|
for record in issue_active_ids:
|
|
if record.issue_state != 'will':
|
|
raise UserError("当前状态不允许上会")
|
|
issue_details = []
|
|
for issue in issue_active_ids:
|
|
issue_details.append((0, 0, {
|
|
'issue_library_id': issue.id,
|
|
}))
|
|
form_id = self.env.ref("room.room_booking_view_form").id
|
|
return {
|
|
"type": "ir.actions.act_window",
|
|
"name": "批量上会",
|
|
"res_model": "room.booking",
|
|
"views": [[form_id, "form"]],
|
|
"context": {
|
|
'default_is_issue': True,
|
|
'default_state': '申请人',
|
|
'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)
|
|
if issue.issue_state != 'will':
|
|
raise UserError("当前状态不允许上会")
|
|
issue_details = [(0, 0, {
|
|
'issue_library_id': issue.id,
|
|
})]
|
|
form_id = self.env.ref("room.room_booking_view_form").id
|
|
return {
|
|
"type": "ir.actions.act_window",
|
|
"name": "单个上会",
|
|
"res_model": "room.booking",
|
|
"views": [[form_id, "form"]],
|
|
"context": {
|
|
'default_is_issue': True,
|
|
'default_state': '申请人',
|
|
'default_issue_meeting_line_ids': issue_details,
|
|
}
|
|
}
|
|
|
|
def approval_details(self):
|
|
self.ensure_one()
|
|
for record in self:
|
|
if not record.issue_approval_id:
|
|
raise UserError('请提交审批后查看')
|
|
form_id = self.env.ref("yuthon_issue.issue_library_approval_form").id
|
|
return{
|
|
"type": "ir.actions.act_window",
|
|
"name": "审批详情",
|
|
"res_model": "issue.approval",
|
|
"views": [[form_id, "form"]],
|
|
"res_id": record.issue_approval_id.id
|
|
}
|
|
|
|
@api.depends('issue_library_line_ids')
|
|
def _compute_issue_library_line_ids(self):
|
|
for record in self:
|
|
# 判断issue_library_line_ids记录集中是否存在关联了issue.library.type的记录
|
|
record.is_party = bool(record.issue_library_line_ids.filtered(lambda rec: rec.council_id))
|
|
record.is_class = bool(record.issue_library_line_ids.filtered(lambda rec: rec.team_meet_id))
|
|
record.is_boss = bool(record.issue_library_line_ids.filtered(lambda rec: rec.board_meet_id))
|
|
record.is_district_state = bool(record.issue_library_line_ids.filtered(lambda rec: rec.district_state_id))
|
|
record.is_district_government = bool(
|
|
record.issue_library_line_ids.filtered(lambda rec: rec.district_government_id))
|
|
record.is_district_party = bool(record.issue_library_line_ids.filtered(lambda rec: rec.district_party_id))
|
|
record.is_note = any([
|
|
bool(record.issue_library_line_ids.filtered(
|
|
lambda rec: rec.issue_approval_decision_id and rec.issue_approval_decision_id.district_state_id)),
|
|
bool(record.issue_library_line_ids.filtered(
|
|
lambda rec: rec.issue_approval_decision_id and rec.issue_approval_decision_id.district_government_id)),
|
|
bool(record.issue_library_line_ids.filtered(
|
|
lambda rec: rec.issue_approval_decision_id and rec.issue_approval_decision_id.district_party_id))
|
|
])
|
|
|
|
|
|
def unlink(self):
|
|
for i in self:
|
|
if i.issue_state == 'on_meet':
|
|
raise UserError('议题已上会,不能删除')
|
|
return super().unlink()
|
|
|
|
@api.depends('name')
|
|
def _compute_name(self):
|
|
for record in self:
|
|
record.name_text = record.name
|
|
|
|
@api.onchange('issue_library_room_line_ids')
|
|
def _onchange_issue_library_room_line_ids(self):
|
|
for record in self.issue_library_room_line_ids:
|
|
if record.meeting_type_id.name == '党委会':
|
|
self.cs_party = record.room_booking_id.name
|
|
elif record.meeting_type_id.name == '班子会':
|
|
self.cs_class = record.room_booking_id.name
|
|
elif record.meeting_type_id.name == '董事会':
|
|
self.cs_boss = record.room_booking_id.name
|
|
|
|
@api.onchange('is_booking')
|
|
def _onchange_is_booking(self):
|
|
if self.is_booking:
|
|
issue_id = self.env['issue.library'].create({'name': self.name})
|
|
self.related_issues_id = issue_id.id
|
|
workflow_record_id = self.env["soong.workflow.record"].search(
|
|
[("res_model", "=", self._name), ("res_id", "=", self.id)])
|
|
self.env['issue.library.approval.line'].create({
|
|
'issue_library_id': issue_id.id,
|
|
'workflow_record_id': workflow_record_id.id,
|
|
'approval_type': workflow_record_id.workflow_id.id,
|
|
'code': self.code,
|
|
'approval_date': fields.Datetime.now(),
|
|
})
|
|
elif self.related_issues_id:
|
|
raise UserError("已经创建了相关的上会记录,不能取消勾选")
|
|
|
|
class IssueLibraryLine(models.Model):
|
|
_name = "issue.library.line"
|
|
_description = '决策清单明细'
|
|
|
|
issue_library_id = fields.Many2one('issue.library')
|
|
issue_approval_decision_id = fields.Many2one('issue.approval.decision', string="上会依据")
|
|
council_id = fields.Many2one(related='issue_approval_decision_id.council_id', string='党总支')
|
|
team_meet_id = fields.Many2one(related='issue_approval_decision_id.team_meet_id', string='经营班子会')
|
|
board_meet_id = fields.Many2one(related='issue_approval_decision_id.board_meet_id', string='董事会')
|
|
district_state_id = fields.Many2one(related='issue_approval_decision_id.district_state_id', string="区国资局")
|
|
district_government_id = fields.Many2one(related='issue_approval_decision_id.district_government_id', string="区政府")
|
|
district_party_id = fields.Many2one(related='issue_approval_decision_id.district_party_id', string="区委组织部")
|
|
ordinal = fields.Char(related='issue_approval_decision_id.sequence', string='序号')
|
|
remarks = fields.Text(related='issue_approval_decision_id.remarks', string="备注")
|
|
|
|
|
|
class IssueLibraryApprovalLine(models.Model):
|
|
_name = "issue.library.approval.line"
|
|
_description = '关联流程明细'
|
|
_order = 'approval_date desc'
|
|
|
|
issue_library_id = fields.Many2one('issue.library', string="关联议题")
|
|
workflow_name = fields.Char(string="标题", compute='compute_issue_soong')
|
|
code = fields.Char(string="流程编号")
|
|
approval_type = fields.Char(string="类型", compute='compute_issue_soong')
|
|
approval_date = fields.Datetime(string="创建日期")
|
|
res_model = fields.Char(string="模型", compute='compute_issue_soong')
|
|
res_id = fields.Char(string="id", compute='compute_issue_soong')
|
|
department_id = fields.Many2one('hr.department', string='部门', compute='compute_issue_soong')
|
|
|
|
@api.depends('code')
|
|
def compute_issue_soong(self):
|
|
for rec in self:
|
|
workflow_record_id = self.env['soong.workflow.record'].search([('code', '=', rec.code)], limit=1)
|
|
if workflow_record_id:
|
|
rec.approval_type = workflow_record_id.workflow_id.name
|
|
rec.res_model = workflow_record_id.res_model
|
|
rec.res_id = workflow_record_id.res_id
|
|
rec.workflow_name = workflow_record_id.name
|
|
record_id = self.env[workflow_record_id.res_model].search([('id', '=', workflow_record_id.res_id)])
|
|
if hasattr(record_id, 'user_id') and record_id.user_id:
|
|
query_user_id = record_id.user_id
|
|
elif hasattr(record_id, 'users_id') and record_id.users_id:
|
|
query_user_id = record_id.users_id
|
|
rec.department_id = query_user_id.employee_ids.department_id.id
|
|
else:
|
|
rec.approval_type = ''
|
|
rec.res_model = ''
|
|
rec.res_id = ''
|
|
rec.department_id = ''
|
|
rec.workflow_name = ''
|
|
|
|
def open_record(self):
|
|
return {
|
|
"type": "ir.actions.act_window",
|
|
"res_model": self.res_model,
|
|
"res_id": int(self.res_id),
|
|
"name": self.workflow_name,
|
|
"view_mode": "form",
|
|
}
|
|
|
|
class IssueLibraryRoomLine(models.Model):
|
|
_name = "issue.library.room.line"
|
|
_description = '关联会议明细'
|
|
|
|
issue_library_id = fields.Many2one('issue.library', string="关联议题")
|
|
room_booking_id = fields.Many2one('room.booking', string="会议名称")
|
|
room_id = fields.Many2one('room.room', string="会议地点")
|
|
meeting_type_id = fields.Many2one('room.meeting.type', string="会议类型")
|
|
approval_date = fields.Datetime(string="创建日期")
|