Merge branch 'master' into dev_zhou

# Conflicts:
#	yuthon_will_task/models/yuthon_will_task.py
This commit is contained in:
李鹏宇
2026-04-29 10:31:41 +08:00
33 changed files with 1016 additions and 65 deletions
@@ -11,6 +11,7 @@ class YuthonWillTask(models.Model):
_name = 'yuthon.will.task'
_description = '日程'
_rec_name = 'name'
_order = 'task_datetime desc'
time_list = [
('0', '0:00'), ('0.25', '0:15'), ('0.5', '0:30'), ('0.75', '0:45'),
@@ -70,6 +71,7 @@ class YuthonWillTask(models.Model):
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)
task_datetime = fields.Datetime(string='任务时间排序', compute='_compute_task_datetime', store=True)
is_this_company = fields.Boolean(string='本公司', default=True)
task_state = fields.Selection([('will', '待办'), ('done', '已办'), ('cancel', '取消')], default='will', string='状态', store=True)
@@ -171,6 +173,27 @@ class YuthonWillTask(models.Model):
for record in will_ids:
record._compute_task_time()
@api.depends('start_date', 'request_hour_from')
def _compute_task_datetime(self):
"""将 start_date + request_hour_from 拼合为 Datetime,用于排序"""
for record in self:
if record.start_date and record.request_hour_from:
try:
hour_float = float(record.request_hour_from)
hours = int(hour_float)
minutes = int(round((hour_float - hours) * 60))
# 存储时转为UTC(界面显示是UTC+8,存储需减8小时)
record.task_datetime = datetime(
record.start_date.year,
record.start_date.month,
record.start_date.day,
hours, minutes, 0
) - timedelta(hours=8)
except Exception:
record.task_datetime = False
else:
record.task_datetime = False
@api.depends('start_date', 'task_week', 'request_hour_from', 'task_type', 'room_booking_id', 'room_booking_id.start_datetime', 'room_booking_id.stop_datetime')
def _compute_task_time(self):
for record in self: