From 41c22c9f6159291103f1574a39fde65db872bfe6 Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Wed, 7 May 2025 16:49:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_will_task/models/yuthon_will_task.py | 10 ++++++++-- yuthon_will_task/views/yuthon_will_task_views.xml | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/yuthon_will_task/models/yuthon_will_task.py b/yuthon_will_task/models/yuthon_will_task.py index 2b79efb9d..02e432691 100644 --- a/yuthon_will_task/models/yuthon_will_task.py +++ b/yuthon_will_task/models/yuthon_will_task.py @@ -26,10 +26,16 @@ class YuthonWillTask(models.Model): users_ids = fields.Many2many('res.users', string='用户', store=True, index=True) user_role_ids = fields.Many2many('soong.user.role', string='角色', store=True, index=True) task_time_ids = fields.Many2many('yuthon.task.time', string='提醒') - start_time = fields.Datetime(string='开始时间', default=fields.Datetime.now) - end_time = fields.Datetime(string='结束时间', default=lambda self: datetime.combine(datetime.now().date(), time(11, 0, 0))) + start_time = fields.Datetime(string='开始时间',default=lambda self: datetime.combine(datetime.now().date(), time(1, 0, 0))) + end_time = fields.Datetime(string='结束时间',default=lambda self: datetime.combine(datetime.now().date(), time(11, 0, 0))) task_state = fields.Selection([('will', '待办'), ('done', '已办'), ('cancel', '取消')], default='will', string='状态', store=True) + @api.constrains('start_time', 'end_time') + def _check_start_end_time(self): + for record in self: + if record.start_time and record.end_time and record.start_time > record.end_time: + raise models.ValidationError("开始时间不能大于结束时间!") + @api.onchange('employee_ids') def _onchange_employee_ids(self): user_ids = [] diff --git a/yuthon_will_task/views/yuthon_will_task_views.xml b/yuthon_will_task/views/yuthon_will_task_views.xml index c47518f9f..8fdf0c81d 100644 --- a/yuthon_will_task/views/yuthon_will_task_views.xml +++ b/yuthon_will_task/views/yuthon_will_task_views.xml @@ -12,6 +12,7 @@ decoration-success="priority == 'important'"> + @@ -94,6 +95,7 @@ decoration-success="priority == 'important'" create="false" edit="false" js_class="custom_task_tree_button"> + @@ -180,7 +182,6 @@ 日程管理 yuthon.will.task tree,calendar,form - [('users_ids', 'in', [uid])] {'search_default_next_seven_days': 1}