Files
gzth/yuthon_issue/wizard/soong_workflow_comment_wizard_inherit.py
T
2026-06-11 15:03:12 +08:00

35 lines
1.5 KiB
Python

# -*- coding: utf-8 -*-
from odoo import fields, models, api
class SoongWorkflowCommentWizard(models.TransientModel):
_inherit = 'soong.workflow.comment.wizard'
is_avoid = fields.Boolean(string='是否回避')
issue_filter_ids = fields.Many2many('issue.library', 'soong_comment_wizard_issue_filter_rel',
'wizard_id', 'issue_id', string='议题过滤')
avoid_issue_ids = fields.Many2many('issue.library', 'soong_comment_wizard_avoid_issue_rel',
'wizard_id', 'issue_id', string='回避议题')
avoid_comment = fields.Char(string='回避意见')
@api.depends('avoid_comment')
def _compute_comment(self):
super()._compute_comment()
for record in self:
if record.avoid_comment:
parts = [record.comment, f'【回避意见】{record.avoid_comment}'] if record.comment else [f'【回避意见】{record.avoid_comment}']
record.comment = " ".join(parts)
@api.onchange('is_avoid')
def _onchange_is_avoid(self):
if not self.is_avoid:
self.avoid_issue_ids = [(5, 0, 0)]
self.avoid_comment = False
def _handle_avoidance(self):
"""回避处理:勾选回避且选了议题时,在对应议题中记录回避"""
if not self.is_avoid or not self.avoid_issue_ids:
return
for issue in self.avoid_issue_ids:
issue.log_avoidance(self.env.user, self.avoid_comment or '')