[FIX] {test_}mail: set automated flag to False for activity scheduled manually
How to reproduce: - Install contacts - Go to any contact - Schedule an activity on the contact by clicking on "Activities" The flag automated of the created activity is set to True which shouldn't be the case (you can check either in the DB or by adding the field with studio). The same happens when scheduling plan, scheduling activities on multiple records in the view list or a plan on multiple records. This fixes the problem by modifying the activity schedule wizard so that it always creates activities with automated flag set to False. Note that that flags is used to distinguish activities created manually from those created automatically. Some flows automatically cancel automated activities (e.g. cancel 'validate my ticket') but those should probably not cancel user defined activities (e.g. 'ask customer to pay'). That's why we must ensure that activity created manually have that flag set to False. Task-3691827 closes odoo/odoo#149965 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
@@ -353,6 +353,9 @@ class MailActivityMixin(models.AbstractModel):
|
||||
It is useful to avoid having various "env.ref" in the code and allow
|
||||
to let the mixin handle access rights.
|
||||
|
||||
Note that unless specified otherwise in act_values, the activities created
|
||||
will have their "automated" field set to True.
|
||||
|
||||
:param date_deadline: the day the activity must be scheduled on
|
||||
the timezone of the user must be considered to set the correct deadline
|
||||
"""
|
||||
|
||||
@@ -89,6 +89,7 @@ class ActivityScheduleCase(MailCommon):
|
||||
**{template.activity_type_id.delay_unit: template.activity_type_id.delay_count}))
|
||||
self.assertEqual(activity.note, template.note)
|
||||
self.assertEqual(activity.summary, template.summary)
|
||||
self.assertFalse(activity.automated)
|
||||
if force_responsible_id:
|
||||
self.assertEqual(activity.user_id, force_responsible_id)
|
||||
else:
|
||||
|
||||
@@ -215,6 +215,7 @@ class MailActivitySchedule(models.TransientModel):
|
||||
template.activity_type_id, force_base_date=self.plan_date_deadline)
|
||||
record.activity_schedule(
|
||||
activity_type_id=template.activity_type_id.id,
|
||||
automated=False,
|
||||
summary=template.summary,
|
||||
note=template.note,
|
||||
user_id=responsible.id,
|
||||
@@ -294,6 +295,7 @@ class MailActivitySchedule(models.TransientModel):
|
||||
def _action_schedule_activities(self):
|
||||
return self._get_applied_on_records().activity_schedule(
|
||||
activity_type_id=self.activity_type_id.id,
|
||||
automated=False,
|
||||
summary=self.summary,
|
||||
note=self.note,
|
||||
user_id=self.activity_user_id.id,
|
||||
|
||||
@@ -91,6 +91,7 @@ class TestActivitySchedule(ActivityScheduleCase):
|
||||
for record in test_records:
|
||||
self.assertActivityCreatedOnRecord(record, {
|
||||
'activity_type_id': self.activity_type_todo,
|
||||
'automated': False,
|
||||
'date_deadline': self.reference_now.date() + timedelta(days=4), # activity type delay
|
||||
'note': '<p>Useful link ...</p>',
|
||||
'summary': 'Write specification',
|
||||
@@ -151,6 +152,7 @@ class TestActivitySchedule(ActivityScheduleCase):
|
||||
for record in test_records:
|
||||
self.assertActivityCreatedOnRecord(record, {
|
||||
'activity_type_id': self.activity_type_call,
|
||||
'automated': False,
|
||||
'date_deadline': self.reference_now.date() + timedelta(days=5), # both types delays
|
||||
'note': False,
|
||||
'summary': False,
|
||||
|
||||
Reference in New Issue
Block a user