summaryrefslogtreecommitdiff
path: root/addons/mail/models
diff options
context:
space:
mode:
Diffstat (limited to 'addons/mail/models')
-rw-r--r--addons/mail/models/ir_actions.py3
-rw-r--r--addons/mail/models/mail_activity.py10
2 files changed, 10 insertions, 3 deletions
diff --git a/addons/mail/models/ir_actions.py b/addons/mail/models/ir_actions.py
index 16abdfeaf8e..8c84144a12a 100644
--- a/addons/mail/models/ir_actions.py
+++ b/addons/mail/models/ir_actions.py
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
-from datetime import date
from dateutil.relativedelta import relativedelta
from odoo import _, api, fields, models
@@ -96,7 +95,7 @@ class ServerActions(models.Model):
'activity_type_id': action.activity_type_id.id,
}
if action.activity_date_deadline_range > 0:
- vals['date_deadline'] = date.today() + relativedelta(**{action.activity_date_deadline_range_type: action.activity_date_deadline_range})
+ vals['date_deadline'] = fields.Date.context_today(action) + relativedelta(**{action.activity_date_deadline_range_type: action.activity_date_deadline_range})
for record in records:
if action.activity_user_type == 'specific':
user = action.activity_user_id
diff --git a/addons/mail/models/mail_activity.py b/addons/mail/models/mail_activity.py
index 6d7b94ad9a3..521caa9eb6b 100644
--- a/addons/mail/models/mail_activity.py
+++ b/addons/mail/models/mail_activity.py
@@ -4,12 +4,15 @@
from collections import defaultdict
from datetime import date, datetime
from dateutil.relativedelta import relativedelta
+import logging
import pytz
from odoo import api, exceptions, fields, models, _
from odoo.tools import pycompat
+_logger = logging.getLogger(__name__)
+
class MailActivityType(models.Model):
""" Activity Types are used to categorize activities. Each type is a different
@@ -579,12 +582,17 @@ class MailActivityMixin(models.AbstractModel):
xml_id of activity type instead of directly giving an activity_type_id.
It is useful to avoid having various "env.ref" in the code and allow
to let the mixin handle access rights.
+
+ :param date_deadline: the day the activity must be scheduled on
+ the timezone of the user must be considered to set the correct deadline
"""
if self.env.context.get('mail_activity_automation_skip'):
return False
if not date_deadline:
- date_deadline = fields.Date.today()
+ date_deadline = fields.Date.context_today(self)
+ if isinstance(date_deadline, datetime):
+ _logger.warning("Scheduled deadline should be a date (got %s)", date_deadline)
if act_type_xmlid:
activity_type = self.sudo().env.ref(act_type_xmlid)
else: