Merge branch 'refs/heads/dev' into dev_zhou
This commit is contained in:
@@ -5,7 +5,6 @@ from odoo.exceptions import UserError
|
||||
import logging
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
now = datetime.now() + timedelta(hours=8)
|
||||
|
||||
|
||||
class YuthonWillTask(models.Model):
|
||||
@@ -23,29 +22,30 @@ class YuthonWillTask(models.Model):
|
||||
employee_ids = fields.Many2many('hr.employee', string='人员', default=lambda self: self.env.user.employee_id)
|
||||
task_time_ids = fields.Many2many('yuthon.task.time', string='提醒')
|
||||
start_time = fields.Datetime(string='开始时间', default=fields.Date.today())
|
||||
end_time = fields.Datetime(string='结束时间', default=lambda self: datetime.combine(now.date(), time(11, 0, 0)))
|
||||
end_time = fields.Datetime(string='结束时间', default=lambda self: datetime.combine(datetime.now().date(), time(11, 0, 0)))
|
||||
|
||||
def will_task_time(self):
|
||||
tasks = self.env['yuthon.will.task'].search([])
|
||||
for task in tasks:
|
||||
# start_time = task.start_time + timedelta(hours=8)
|
||||
now = datetime.now() + timedelta(hours=8)
|
||||
start_time = task.start_time + timedelta(hours=8)
|
||||
_logger.info("定时任务执行中")
|
||||
_logger.info("判断前now:{}---start:{}".format(now, task.start_time))
|
||||
if now <= task.start_time:
|
||||
_logger.info("判断后now:{}---start:{}".format(now, task.start_time))
|
||||
_logger.info("判断前now:{}---start:{}".format(now, start_time))
|
||||
if now <= start_time:
|
||||
_logger.info("判断后now:{}---start:{}".format(now, start_time))
|
||||
if task.task_time_ids:
|
||||
for task_time in task.task_time_ids:
|
||||
duration = self._compute_duration(task_time)
|
||||
day_now = (now + duration).day
|
||||
day_start = task.start_time.day
|
||||
day_start = start_time.day
|
||||
hour_now = (now + duration).hour
|
||||
hour_start = task.start_time.hour
|
||||
hour_start = start_time.hour
|
||||
min_now = (now + duration).minute
|
||||
min_start = task.start_time.minute
|
||||
min_start = start_time.minute
|
||||
if day_now == day_start and hour_now == hour_start and min_now == min_start:
|
||||
task.add_comment()
|
||||
else:
|
||||
if now.day == task.start_time.day and now.hour == task.start_time.hour and now.minute == task.start_time.minute:
|
||||
if now.day == start_time.day and now.hour == start_time.hour and now.minute == start_time.minute:
|
||||
task.add_comment()
|
||||
|
||||
def _compute_duration(self, task_time):
|
||||
|
||||
Reference in New Issue
Block a user