添加功能

This commit is contained in:
李鹏宇
2025-12-24 10:25:50 +08:00
parent 8ea23b7b18
commit d4026811f0
2 changed files with 5 additions and 5 deletions
+4 -4
View File
@@ -82,7 +82,7 @@ class YuthonWillTask(models.Model):
document_ids = fields.Many2many('ir.attachment', string="附件")
address = fields.Char(string='地点')
start_date = fields.Date(string='开始日期', default=fields.Date.today)
task_time = fields.Char(string='任务时间', compute='_compute_task_time')
task_time = fields.Char(string='任务时间')
is_this_company = fields.Boolean(string='本公司', default=True)
task_state = fields.Selection([('will', '待办'), ('done', '已办'), ('cancel', '取消')], default='will', string='状态', store=True)
@@ -116,8 +116,8 @@ class YuthonWillTask(models.Model):
if record.start_date:
record.task_week = weekdays[record.start_date.weekday()]
@api.depends('start_date', 'request_hour_from', 'request_hour_to')
def _compute_task_time(self):
@api.constrains('start_date', 'request_hour_from', 'request_hour_to')
def _check_task_time(self):
for record in self:
date_str = ""
if record.start_date:
@@ -151,7 +151,7 @@ class YuthonWillTask(models.Model):
from_time = hour_mapping.get(record.request_hour_from, "")
to_time = hour_mapping.get(record.request_hour_to, "")
if date_str and from_time and to_time:
record.task_time = f"{date_str} {from_time}"
record.task_time = f"{date_str} {record.task_week} {from_time}"
else:
record.task_time = ""
@@ -73,7 +73,7 @@
<group>
<label for="start_date"/>
<div class="d-inline-flex w-100">
<field name="start_date" string="日期" class="me-2" style="max-width: 10rem !important;"/>
<field name="start_date" string="日期" class="me-2" style="max-width: 6rem !important;"/>
<field name="task_week" string="" class="me-2" style="max-width: 4rem !important;"/>
<field name="request_hour_from" string=" " class="ms-2" style="max-width: 5rem !important;"/>→
<field name="request_hour_to" string=" " class="ms-2" style="max-width: 5rem !important;"/>