From 399ba180b834ac648e9ca67bba8caa5ff6866d93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Mon, 9 Mar 2026 14:21:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E7=A8=8B=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_will_task/models/yuthon_will_task.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/yuthon_will_task/models/yuthon_will_task.py b/yuthon_will_task/models/yuthon_will_task.py index 0b54bb1aa..9606ce845 100644 --- a/yuthon_will_task/models/yuthon_will_task.py +++ b/yuthon_will_task/models/yuthon_will_task.py @@ -67,7 +67,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='任务时间') + task_time = fields.Char(string='任务时间', compute='_compute_task_time', store=True) is_this_company = fields.Boolean(string='本公司', default=True) task_state = fields.Selection([('will', '待办'), ('done', '已办'), ('cancel', '取消')], default='will', string='状态', store=True) @@ -123,10 +123,10 @@ class YuthonWillTask(models.Model): will_ids = self.env["yuthon.will.task"].browse( self._context.get('active_ids', self._context.get('active_id'))) for record in will_ids: - record._check_task_time() + record._compute_task_time() - @api.constrains('start_date', 'request_hour_from', 'request_hour_to', 'task_type', 'room_booking_id') - def _check_task_time(self): + @api.depends('start_date', 'task_week', 'request_hour_from', 'task_type', 'room_booking_id', 'room_booking_id.stop_datetime') + def _compute_task_time(self): for record in self: date_str = "" if record.start_date: @@ -158,8 +158,7 @@ class YuthonWillTask(models.Model): '23': '23:00', '23.25': '23:15', '23.5': '23:30', '23.75': '23:45' } 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: + if date_str and from_time: base_time = f"{date_str} {record.task_week} {from_time}" # 会议类型:拼接会议室预订的结束时间 if record.task_type == 'meet' and record.room_booking_id and record.room_booking_id.stop_datetime: