From 6db165a809aa2622a4fa85391367739b95aa0bec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Wed, 11 Mar 2026 16:03:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=9A=E6=94=AF=E5=A7=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/yuthon_official_branch_party.py | 129 ++++++++++++++++++ .../yuthon_official_branch_party_views.xml | 110 +++++++++++++++ 2 files changed, 239 insertions(+) create mode 100644 yuthon_official/models/yuthon_official_branch_party.py create mode 100644 yuthon_official/views/yuthon_official_branch_party_views.xml diff --git a/yuthon_official/models/yuthon_official_branch_party.py b/yuthon_official/models/yuthon_official_branch_party.py new file mode 100644 index 000000000..310196a47 --- /dev/null +++ b/yuthon_official/models/yuthon_official_branch_party.py @@ -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(), + }) diff --git a/yuthon_official/views/yuthon_official_branch_party_views.xml b/yuthon_official/views/yuthon_official_branch_party_views.xml new file mode 100644 index 000000000..d14d1f5e0 --- /dev/null +++ b/yuthon_official/views/yuthon_official_branch_party_views.xml @@ -0,0 +1,110 @@ + + + + yuthon.official.branch.party.tree + yuthon.official.branch.party + + + + + + + + + + + + yuthon.official.branch.party.form + yuthon.official.branch.party + +
+
+ +
+ + + + + + + + + + + + + + + + + + +
+

+ +

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + + yuthon.official.branch.party.search + yuthon.official.branch.party + + + + + + + + + + + + 党支委发文 + [('is_company', '=', True)] + yuthon.official.branch.party + tree,form + +