65 lines
2.3 KiB
Python
65 lines
2.3 KiB
Python
from odoo import models, fields, api
|
|
from odoo.exceptions import ValidationError
|
|
|
|
|
|
class IssueTicket(models.Model):
|
|
_name = "issue.ticket"
|
|
_description = "问题单"
|
|
_inherit = ["mail.thread", "mail.activity.mixin"]
|
|
_order = "priority desc, create_date desc"
|
|
|
|
name = fields.Char(string="问题标题", required=True, tracking=True)
|
|
description = fields.Text(string="问题描述")
|
|
reporter_id = fields.Many2one(
|
|
"res.users", string="报告人", default=lambda self: self.env.user
|
|
)
|
|
assigned_id = fields.Many2one("res.users", string="负责人", tracking=True)
|
|
priority = fields.Selection(
|
|
[("0", "低"), ("1", "普通"), ("2", "高"), ("3", "紧急")],
|
|
default="1",
|
|
string="优先级",
|
|
tracking=True,
|
|
)
|
|
state = fields.Selection(
|
|
[
|
|
("draft", "草稿"),
|
|
("open", "已打开"),
|
|
("in_progress", "处理中"),
|
|
("done", "已解决"),
|
|
("cancelled", "已取消"),
|
|
],
|
|
default="draft",
|
|
string="状态",
|
|
tracking=True,
|
|
)
|
|
deadline = fields.Date(string="截止日期")
|
|
tag_ids = fields.Many2many("issue.ticket.tag", string="标签")
|
|
work_end = fields.Boolean(string="工作结束", default=False, tracking=True)
|
|
remark = fields.Html(string="备注")
|
|
# 新增:问题明细关联
|
|
line_ids = fields.One2many(
|
|
"issue.ticket.detail", "ticket_id", string="问题明细", copy=True
|
|
)
|
|
reproduce_steps = fields.Selection(
|
|
[
|
|
("step_1", "步骤 1: 打开应用程序"),
|
|
("step_2", "步骤 2: 点击“提交”按钮"),
|
|
("step_3", "步骤 3: 等待错误提示"),
|
|
],
|
|
string="选择复现步骤",
|
|
help="选择一个常见的复现步骤,或者在下方文本框中详细描述",
|
|
)
|
|
|
|
detailed_reproduce_steps = fields.Text(
|
|
string="详细复现步骤", help="请详细描述复现步骤,包含详细操作及截图(如有)"
|
|
)
|
|
|
|
@api.constrains("deadline")
|
|
def _check_deadline(self):
|
|
for rec in self:
|
|
if rec.deadline and rec.deadline < fields.Date.today():
|
|
raise ValidationError("截止日期不能早于今天。")
|
|
|
|
def action_set_draft(self):
|
|
self.state = "draft"
|