From 3b851f7f9050c3ceb0f4f30ae0f7f919c1359368 Mon Sep 17 00:00:00 2001 From: pengyuthon Date: Wed, 24 Dec 2025 10:07:32 +0800 Subject: [PATCH] 1 --- yuthon_will_task/models/yuthon_will_task.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/yuthon_will_task/models/yuthon_will_task.py b/yuthon_will_task/models/yuthon_will_task.py index 24069490a..93892bd7f 100644 --- a/yuthon_will_task/models/yuthon_will_task.py +++ b/yuthon_will_task/models/yuthon_will_task.py @@ -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='任务时间') + task_time = fields.Char(string='任务时间', compute='_compute_task_time') is_this_company = fields.Boolean(string='本公司', default=True) task_state = fields.Selection([('will', '待办'), ('done', '已办'), ('cancel', '取消')], default='will', string='状态', store=True) @@ -106,8 +106,18 @@ class YuthonWillTask(models.Model): store=True, default=lambda self: [(6, 0, [self.env.user.id])] ) - @api.constrains('start_date', 'request_hour_from', 'request_hour_to') - def _check_task_time(self): + employee_id = fields.Many2one('hr.employee', string="经办人", default=lambda self: self.env.user.employee_id) + task_week = fields.Char(string="周", readonly=True, compute='_compute_task_week') + + @api.depends('start_date') + def _compute_task_week(self): + weekdays = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"] + for record in self: + 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): for record in self: date_str = "" if record.start_date: