!9585 Merge branch 'dev' of <a href="https://gitee.com/jinan-pengyusen-data/gzth">https://gitee.com/jinan-pengyusen-data/gzth</a> into dev_wang
Merge pull request !9585 from 李鹏宇/dev_wang
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import api, fields, models, tools
|
||||
from odoo.exceptions import ValidationError, UserError
|
||||
|
||||
|
||||
class YuthonOfficialBranchParty(models.Model):
|
||||
_name = 'yuthon.official.branch.party'
|
||||
_description = '党支委发文'
|
||||
_inherit = ['mail.thread.main.attachment', 'mail.activity.mixin', 'soong.workflow.mixin']
|
||||
_rec_name = 'name'
|
||||
|
||||
name = fields.Char(string="名称")
|
||||
users_id = fields.Many2one('res.users', string="拟稿人", default=lambda self: self.env.user)
|
||||
department_id = fields.Many2one(related='users_id.employee_id.department_id', string="拟稿部门")
|
||||
company_id = fields.Many2one(related='users_id.company_id', string="公司")
|
||||
company_id1 = fields.Many2one('res.company', string="公司前缀")
|
||||
code = fields.Char(string="编号", default=lambda self: self.env['ir.sequence'].next_by_code('official_code'))
|
||||
official_type_id = fields.Many2one('official.type', string="文件类型")
|
||||
is_cold = fields.Boolean(string="发文编号")
|
||||
reference_cold = fields.Char(string="发文字号")
|
||||
major_event_category = fields.Integer(string="重大事项所属类别")
|
||||
remarks = fields.Char(string="备注事项")
|
||||
main_text = fields.Text(string='文件内容')
|
||||
main_flats_ids = fields.Many2many(
|
||||
'main.flats',
|
||||
'yuthon_official_branch_party_main_flats_rel',
|
||||
'official_id',
|
||||
'flat_id',
|
||||
string="主送单位"
|
||||
)
|
||||
copy_flats_ids = fields.Many2many(
|
||||
'main.flats',
|
||||
'yuthon_official_branch_party_copy_flats_rel',
|
||||
'official_id',
|
||||
'flat_id',
|
||||
string="抄送单位"
|
||||
)
|
||||
servings_number = fields.Integer(string="份数")
|
||||
urgency_level = fields.Selection([('normal', '一般'), ('urgent', '紧急'), ('extra_urgent', '特急')], string="紧急程度", default='normal')
|
||||
secret_level = fields.Selection([('normal', '一般'), ('urgent', '秘密'), ('secret', '机密'), ('so_secret', '绝密')],
|
||||
string="密级")
|
||||
date = fields.Datetime(string="拟稿日期", default=fields.Datetime.now)
|
||||
statu = fields.Selection([('drft', '草稿'), ('going', '执行中'), ('cancel', '已取消'), ('done', '已完成')],
|
||||
string="状态", default='drft')
|
||||
deadline = fields.Datetime(string="办理期限")
|
||||
red_suit = fields.Char(string="套红")
|
||||
official_documents_ids = fields.Many2many('documents.document', string="附件")
|
||||
active = fields.Boolean('Active', default=True, tracking=True)
|
||||
work_end = fields.Boolean(string="结束")
|
||||
is_meet = fields.Boolean(string="是否上会")
|
||||
issues_result = fields.Html(string="会议结果")
|
||||
related_issues_id = fields.Many2one('issue.library', string="关联议题")
|
||||
is_company = fields.Boolean(string="本公司", default=True, compute='_compute_is_company', search='_search_part_of_company')
|
||||
|
||||
@api.depends_context('uid', 'company')
|
||||
@api.depends('company_id')
|
||||
def _compute_is_company(self):
|
||||
active_company_ids = self.env.companies
|
||||
for employee in self:
|
||||
employee.is_company = employee.company_id in active_company_ids
|
||||
|
||||
def _search_part_of_company(self, operator, value):
|
||||
company_ids = self.env.companies.ids
|
||||
if not value:
|
||||
operator = '!=' if operator == '=' else '='
|
||||
if operator == '=':
|
||||
return [('company_id', 'in', company_ids)]
|
||||
else:
|
||||
return [('company_id', 'not in', company_ids)]
|
||||
|
||||
def _get_default_name_title(self):
|
||||
return self._description if self._description else self._name
|
||||
|
||||
name_title = fields.Char(default=_get_default_name_title)
|
||||
self_users_ids = fields.Many2many('res.users', string="当前经办人", default=lambda self: [(6, 0, [self.env.user.id])])
|
||||
|
||||
@api.onchange('is_cold')
|
||||
def onchange_is_cold(self):
|
||||
if self.is_cold:
|
||||
self.onchange_company_id()
|
||||
else:
|
||||
self.reference_cold = False
|
||||
|
||||
@api.onchange('company_id')
|
||||
def onchange_company_id(self):
|
||||
current_year = fields.Date.today().year
|
||||
self.reference_cold = False
|
||||
if self.company_id and self.company_id.name:
|
||||
company_name = self.company_id.name
|
||||
prefix_map = {
|
||||
'集团本部': '穗天投',
|
||||
'天河粮储': '天粮储司',
|
||||
'天河物管': '穗天物'
|
||||
}
|
||||
prefix = prefix_map.get(company_name)
|
||||
if not prefix:
|
||||
return
|
||||
year_str = f"〔{current_year}〕"
|
||||
domain = [
|
||||
('company_id', '=', self.company_id.id),
|
||||
('reference_cold', 'like', f"{prefix}{year_str}%")
|
||||
]
|
||||
last_record = self.search(domain, order='reference_cold desc', limit=1)
|
||||
if last_record and last_record.reference_cold:
|
||||
try:
|
||||
seq_str = last_record.reference_cold.split(year_str)[1].rsplit('号', 1)[0]
|
||||
last_seq = int(seq_str)
|
||||
next_seq = last_seq + 1
|
||||
except (IndexError, ValueError):
|
||||
next_seq = 1
|
||||
else:
|
||||
next_seq = 1
|
||||
seq_str = f"{next_seq}"
|
||||
self.reference_cold = f"{prefix}{year_str}{seq_str}号"
|
||||
|
||||
@api.onchange('is_meet')
|
||||
def _onchange_is_meet(self):
|
||||
if self.is_meet:
|
||||
issue_id = self.env['issue.library'].create({'name': self.name, 'is_invisible_workflow': True})
|
||||
self.related_issues_id = issue_id.id
|
||||
self.env['issue.library.approval.line'].create({
|
||||
'issue_library_id': issue_id.id,
|
||||
'workflow_name': self.name,
|
||||
'approval_type': self.workflow_id.name,
|
||||
'res_model': self._name,
|
||||
'res_id': self.id,
|
||||
'code': self.code,
|
||||
'approval_date': fields.Datetime.now(),
|
||||
})
|
||||
@@ -0,0 +1,110 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<record id="yuthon_official_branch_party_tree" model="ir.ui.view">
|
||||
<field name="name">yuthon.official.branch.party.tree</field>
|
||||
<field name="model">yuthon.official.branch.party</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree>
|
||||
<field name="name"/>
|
||||
<field name="reference_cold"/>
|
||||
<field name="department_id"/>
|
||||
<field name="date"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="yuthon_official_branch_party_form" model="ir.ui.view">
|
||||
<field name="name">yuthon.official.branch.party.form</field>
|
||||
<field name="model">yuthon.official.branch.party</field>
|
||||
<field name="arch" type="xml">
|
||||
<form create="0">
|
||||
<header>
|
||||
<field name="statu" widget="statusbar"/>
|
||||
</header>
|
||||
<sheet>
|
||||
<widget name="web_ribbon" title="普件" bg_color="text-bg-success"
|
||||
invisible="urgency_level != 'normal'"/>
|
||||
<widget name="web_ribbon" title="急件" bg_color="text-bg-warning"
|
||||
invisible="urgency_level != 'urgent'"/>
|
||||
<widget name="web_ribbon" title="特急" bg_color="text-bg-danger"
|
||||
invisible="urgency_level != 'emergency'"/>
|
||||
<group col="4">
|
||||
<group>
|
||||
<field name="code" string="流水号" readonly="1"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="urgency_level" readonly="1"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="is_meet"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="related_issues_id" invisible="is_meet == False"/>
|
||||
</group>
|
||||
</group>
|
||||
<div class="col-12 text-center">
|
||||
<h1>
|
||||
<field name="name_title" readonly="1"/>
|
||||
</h1>
|
||||
</div>
|
||||
<div class="oe_title">
|
||||
<label for="name"/>
|
||||
<h1>
|
||||
<field name="name" required="1"/>
|
||||
</h1>
|
||||
</div>
|
||||
<group string="文件基本信息">
|
||||
<group col="2">
|
||||
<field name="is_back" invisible="1"/>
|
||||
<field name="company_id" invisible="1"/>
|
||||
<field name="work_end" invisible="1"/>
|
||||
<field name="company_id1"/>
|
||||
<field name="secret_level"/>
|
||||
<field name="official_type_id" options="{'no_create': True}"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="is_cold"/>
|
||||
<field name="reference_cold" invisible="not is_cold"/>
|
||||
<field name="main_flats_ids" options="{'no_create': True, 'no_open': True}" widget="many2many_tags"/>
|
||||
<field name="copy_flats_ids" options="{'no_create': True, 'no_open': True}" widget="many2many_tags"/>
|
||||
<field name="date"/>
|
||||
<field name="issues_result" invisible="is_meet == False"/>
|
||||
</group>
|
||||
</group>
|
||||
<group col="2" string="拟稿信息">
|
||||
<group>
|
||||
<field name="users_id"/>
|
||||
<field name="official_documents_ids" widget="preview_many2many"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="department_id"/>
|
||||
</group>
|
||||
</group>
|
||||
<group string="文件内容">
|
||||
<field name="main_text" string=" "/>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="yuthon_official_branch_party_search" model="ir.ui.view">
|
||||
<field name="name">yuthon.official.branch.party.search</field>
|
||||
<field name="model">yuthon.official.branch.party</field>
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<filter string="草稿" name="Drft" domain="[('statu', '=', 'drft')]"/>
|
||||
<filter string="执行中" name="Going" domain="[('statu', '=', 'going')]"/>
|
||||
<filter string="已取消" name="Cancel" domain="[('statu', '=', 'cancel')]"/>
|
||||
<filter string="已完成" name="Done" domain="[('statu', '=', 'done')]"/>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="yuthon_official_branch_party_action" model="ir.actions.act_window">
|
||||
<field name="name">党支委发文</field>
|
||||
<field name="domain">[('is_company', '=', True)]</field>
|
||||
<field name="res_model">yuthon.official.branch.party</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user