Merge pull request !12174 from 李鹏宇/dev
This commit is contained in:
李鹏宇
2026-06-18 03:26:28 +00:00
committed by Gitee
2 changed files with 22 additions and 23 deletions
+21 -22
View File
@@ -55,7 +55,7 @@ class YuthonOfficial(models.Model):
date = fields.Datetime(string="拟稿日期", default=fields.Datetime.now)
official_statu = fields.Selection([('done', '办结'), ('approval', '审核')], string="公文环节")
users_id = fields.Many2one('res.users', string="拟稿人", default=lambda self: self.env.user)
department_id = fields.Many2one(related='users_id.employee_ids.department_id', string="拟稿部门")
department_id = fields.Many2one('hr.department', string="拟稿部门")
company_id = fields.Many2one(related='users_id.company_id', string="公司")
company_id1 = fields.Many2one('res.company', string="公司前缀", default=lambda self: self.env.company)
is_meet = fields.Boolean(string="是否上会")
@@ -90,6 +90,21 @@ class YuthonOfficial(models.Model):
is_company = fields.Boolean(string="本公司", default=True, compute='_compute_is_company',
search='_search_part_of_company')
@api.onchange('users_id')
def _onchange_users_id(self):
employee = self.users_id.employee_id
if employee:
self.department_id = employee.department_id
dept_ids = [employee.department_id.id] + employee.department_ids.ids
return {'domain': {
'department_id': [('id', 'in', dept_ids)],
}}
else:
self.department_id = False
return {'domain': {
'department_id': [('id', 'in', [])],
}}
@api.depends('code')
def _compute_workflow(self):
for record in self:
@@ -109,25 +124,19 @@ class YuthonOfficial(models.Model):
employee.is_company = employee.company_id in active_company_ids
def _search_part_of_company(self, operator, value):
company_ids = self.env.companies.ids # 获取公司ID列表
# 处理反向操作符
company_ids = self.env.companies.ids
if not value:
operator = '!=' if operator == '=' else '='
# 使用company_id in company_ids的结构
if operator == '=':
return [('company_id', 'in', company_ids)]
else: # operator == '!='
else:
return [('company_id', 'not in', company_ids)]
@api.depends('name')
def _compute_text(self):
"""
计算text字段,值等于name字段
"""
for record in self:
record.text = record.name or ''
def end_approval(self):
self.write({'work_end': True})
if any(flat.name == '广州市天河投资集团有限公司' for flat in self.main_flats_ids):
@@ -304,12 +313,10 @@ class YuthonOfficial(models.Model):
def button_transfer(self):
"""转交按钮"""
# 这里可以添加转交的逻辑
pass
def button_withdraw(self):
"""收回按钮"""
# 这里可以添加收回的逻辑
pass
@@ -319,7 +326,6 @@ class YuthonPropertyOfficial(models.Model):
_inherit = ['soong.workflow.mixin', 'mail.thread.main.attachment', 'mail.activity.mixin']
_rec_name = 'name'
name = fields.Char(string="标题")
text = fields.Text(string="标题", compute='_compute_text', store=True)
code = fields.Char(string="编号", default=lambda self: self.env['ir.sequence'].next_by_code('official_code'))
@@ -418,21 +424,16 @@ class YuthonPropertyOfficial(models.Model):
employee.is_company = employee.company_id in active_company_ids
def _search_part_of_company(self, operator, value):
company_ids = self.env.companies.ids # 获取公司ID列表
# 处理反向操作符
company_ids = self.env.companies.ids
if not value:
operator = '!=' if operator == '=' else '='
# 使用company_id in company_ids的结构
if operator == '=':
return [('company_id', 'in', company_ids)]
else: # operator == '!='
else:
return [('company_id', 'not in', company_ids)]
@api.depends('name')
def _compute_text(self):
"""
计算text字段,值等于name字段
"""
for record in self:
record.text = record.name or ''
@@ -571,10 +572,8 @@ class YuthonPropertyOfficial(models.Model):
def button_transfer(self):
"""转交按钮"""
# 这里可以添加转交的逻辑
pass
def button_withdraw(self):
"""收回按钮"""
# 这里可以添加收回的逻辑
pass
pass
@@ -4,7 +4,7 @@
<field name="name">yuthon.sub.enterprises.tree</field>
<field name="model">yuthon.sub.enterprises</field>
<field name="arch" type="xml">
<tree string="文件处理(子企业)">
<tree string="文件处理(子企业)" limit="15">
<field name="code"/>
<field name="name"/>
<field name="approve_state" widget="badge" decoration-danger="approve_state == 'end'"