!10760 日程结束日期

Merge pull request !10760 from 李鹏宇/dev
This commit is contained in:
李鹏宇
2026-04-13 15:35:06 +00:00
committed by Gitee
2 changed files with 38 additions and 7 deletions
+12 -3
View File
@@ -1,7 +1,7 @@
from odoo import api, fields, models, modules
import datetime
from datetime import datetime, timedelta, time
from odoo.exceptions import UserError
from odoo.exceptions import UserError, ValidationError
import logging
_logger = logging.getLogger(__name__)
@@ -49,8 +49,8 @@ class YuthonWillTask(models.Model):
hour = (now.hour + 1) % 24
return str(hour)
request_hour_from = fields.Selection(time_list, string='开始时间')
request_hour_to = fields.Selection(time_list, string='结束时间')
request_hour_from = fields.Selection(time_list, string='开始时间', default=_default_request_hour_from)
request_hour_to = fields.Selection(time_list, string='结束时间', default=_default_request_hour_to)
priority = fields.Selection([('important', '重要不紧急'), ('urgent', '紧急不重要'), ('very_urgent', '重要且紧急')], string='优先级')
code = fields.Char(string="任务编号", default=lambda self: self.env['ir.sequence'].next_by_code('task_code'))
user_id = fields.Many2one('res.users', string="创建人", default=lambda self: self.env.user)
@@ -67,6 +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)
end_date = fields.Date(string='结束日期', default=fields.Date.today)
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)
@@ -87,6 +88,14 @@ class YuthonWillTask(models.Model):
], string='类型', default='task')
room_booking_id = fields.Many2one('room.booking', string='会议室')
@api.onchange('start_date', 'end_date')
def _onchange_date_range(self):
if self.start_date and self.end_date:
start = fields.Datetime.from_string(self.start_date)
end = fields.Datetime.from_string(self.end_date)
if start > end:
raise ValidationError("开始日期必须小于结束日期,请重新设置。")
def back_wecom_msg(self):
self.env['wecom.apps'].back_message(category='task', msg_id=self.msg_id)
@@ -69,6 +69,7 @@
</group>
<group>
<field name="priority"/>
<field name="task_type" invisible="1"/>
</group>
</group>
<div class="oe_title">
@@ -90,7 +91,7 @@
</group>
</group>
<group col="2">
<group>
<group invisible="task_type != 'meet'">
<label for="request_hour_to" string="结束日期"/>
<div class="d-inline-flex w-100">
<field name="start_date" string="结束日期" class="me-2"
@@ -100,6 +101,16 @@
style="max-width: 5rem !important;"/>
</div>
</group>
<group invisible="task_type == 'meet'">
<label for="request_hour_to" string="结束日期"/>
<div class="d-inline-flex w-100">
<field name="end_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_to" string=" " class="ms-2"
style="max-width: 5rem !important;"/>
</div>
</group>
</group>
<group>
<field name="task_time_ids" widget="many2many_tags" required="1"/>
@@ -184,6 +195,7 @@
</group>
<group>
<field name="priority"/>
<field name="task_type" invisible="1"/>
</group>
</group>
<div class="oe_title">
@@ -205,12 +217,22 @@
</group>
</group>
<group col="2">
<group>
<group invisible="task_type != 'meet'">
<label for="request_hour_to" string="结束日期"/>
<div class="d-inline-flex w-100">
<field name="start_date" string="结束日期" class="me-2" readonly="1"
<field name="start_date" string="结束日期" class="me-2"
style="max-width: 6rem !important;"/>
<field name="task_week" string="" class="me-2" readonly="1" style="max-width: 4rem !important;"/>
<field name="task_week" string="" class="me-2" style="max-width: 4rem !important;"/>
<field name="request_hour_to" string=" " class="ms-2"
style="max-width: 5rem !important;"/>
</div>
</group>
<group invisible="task_type == 'meet'">
<label for="request_hour_to" string="结束日期"/>
<div class="d-inline-flex w-100">
<field name="end_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_to" string=" " class="ms-2"
style="max-width: 5rem !important;"/>
</div>