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
+5 -3
View File
@@ -10,12 +10,10 @@ import logging
logger = logging.getLogger(__name__)
def get_is_leader_domain(is_leader: bool):
operator = 'in' if is_leader else 'not in'
return [('user_role_ids.name', operator, ['董事长', '分管领导', '总经理', '部门副经理', '副总经理', '司机'])]
class YuthonWillTask(http.Controller):
@http.route('/yuthon/yuthon/will/task', methods=['POST'], type='http', auth='none', csrf=False)
@@ -87,6 +85,9 @@ class YuthonWillTask(http.Controller):
start = int(kwargs.get('start'))
users_id = int(kwargs.get('users_id'))
_filter = kwargs.get('filter')
state = kwargs.get('state')
order = 'start_date desc' if state == 'done' else 'start_date asc'
domain = [('users_ids', 'in', [users_id])]
logger.info(f"{kwargs}")
logger.info(f"{kwargs}")
@@ -104,11 +105,12 @@ class YuthonWillTask(http.Controller):
end_date = start_date + timedelta(days=6)
domain = expression.AND([domain, [('start_date', '>=', start_date), ('start_date', '<=', end_date)]])
domain = expression.AND([domain, [('task_state', '=', state)]])
WillTask = request.env['yuthon.will.task'].sudo()
request_hour_selection = WillTask.fields_get(allfields=['request_hour_from'])['request_hour_from']['selection']
state_dict = dict(WillTask.fields_get(allfields=['task_state'])['task_state']['selection'])
result_list = []
task_ids = request.env['yuthon.will.task'].sudo().search(domain, offset=start, limit=20, order='start_date desc')
task_ids = request.env['yuthon.will.task'].sudo().search(domain, offset=start, limit=20, order=order)
for task in task_ids:
weekday_str = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"][task.start_date.weekday()]
result = {
@@ -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:
@@ -152,7 +152,8 @@
decoration-danger="priority == 'very_urgent'"
decoration-info="priority == 'urgent'"
decoration-success="priority == 'important'" create="false" edit="false"
js_class="custom_task_tree_button" limit="15">
js_class="custom_task_tree_button" limit="15" default_order="task_datetime desc">
<field name='task_datetime' column_invisible="1"/>
<field name='start_date' column_invisible="1"/>
<field name='task_time'/>
<field name='name' required="1"/>