[IMP] (test_)mail: allow attachment propagation in all activity feedback methods
Activity-level feedback method accepts attachment_ids but not its mixin-level counterpart. This commit fixes that by adding the parameter. The activity-level action_feedback_schedule_next method now also accepts attachments in addition to the feedback, making the API coherent through all entry points. At activity level ``action_done`` now goes through ``action_feedback``. This means it now has two main methods * ``action_feedback``; * ``action_feedback_schedule_next``; All methods finally end up calling ``_action_done`` and correctly propagate feedback and attachments. We have a bit less entry points with possible API changes. Test mail models are updated to be able to use this small addition. Task-2710804 (Mail: Clean MailThread API) Part-of: odoo/odoo#86393
This commit is contained in:
@@ -472,20 +472,20 @@ class MailActivity(models.Model):
|
||||
def action_done(self):
|
||||
""" Wrapper without feedback because web button add context as
|
||||
parameter, therefore setting context to feedback """
|
||||
messages, next_activities = self._action_done()
|
||||
return messages.ids and messages.ids[0] or False
|
||||
return self.action_feedback()
|
||||
|
||||
def action_feedback(self, feedback=False, attachment_ids=None):
|
||||
self = self.with_context(clean_context(self.env.context))
|
||||
messages, next_activities = self._action_done(feedback=feedback, attachment_ids=attachment_ids)
|
||||
return messages.ids and messages.ids[0] or False
|
||||
messages, _next_activities = self.with_context(
|
||||
clean_context(self.env.context)
|
||||
)._action_done(feedback=feedback, attachment_ids=attachment_ids)
|
||||
return messages[0].id if messages else False
|
||||
|
||||
def action_done_schedule_next(self):
|
||||
""" Wrapper without feedback because web button add context as
|
||||
parameter, therefore setting context to feedback """
|
||||
return self.action_feedback_schedule_next()
|
||||
|
||||
def action_feedback_schedule_next(self, feedback=False):
|
||||
def action_feedback_schedule_next(self, feedback=False, attachment_ids=None):
|
||||
ctx = dict(
|
||||
clean_context(self.env.context),
|
||||
default_previous_activity_type_id=self.activity_type_id.id,
|
||||
@@ -493,7 +493,7 @@ class MailActivity(models.Model):
|
||||
default_res_id=self.res_id,
|
||||
default_res_model=self.res_model,
|
||||
)
|
||||
messages, next_activities = self._action_done(feedback=feedback) # will unlink activity, dont access self after that
|
||||
_messages, next_activities = self._action_done(feedback=feedback, attachment_ids=attachment_ids) # will unlink activity, dont access self after that
|
||||
if next_activities:
|
||||
return False
|
||||
return {
|
||||
|
||||
@@ -475,7 +475,7 @@ class MailActivityMixin(models.AbstractModel):
|
||||
activities.write(write_vals)
|
||||
return activities
|
||||
|
||||
def activity_feedback(self, act_type_xmlids, user_id=None, feedback=None):
|
||||
def activity_feedback(self, act_type_xmlids, user_id=None, feedback=None, attachment_ids=None):
|
||||
""" Set activities as done, limiting to some activity types and
|
||||
optionally to a given user. """
|
||||
if self.env.context.get('mail_activity_automation_skip'):
|
||||
@@ -488,7 +488,7 @@ class MailActivityMixin(models.AbstractModel):
|
||||
return False
|
||||
activities = self.activity_search(act_type_xmlids, user_id=user_id)
|
||||
if activities:
|
||||
activities.action_feedback(feedback=feedback)
|
||||
activities.action_feedback(feedback=feedback, attachment_ids=attachment_ids)
|
||||
return True
|
||||
|
||||
def activity_unlink(self, act_type_xmlids, user_id=None):
|
||||
|
||||
@@ -60,8 +60,10 @@ class MailTestActivity(models.Model):
|
||||
summary=action_summary
|
||||
)
|
||||
|
||||
def action_close(self, action_feedback):
|
||||
self.activity_feedback(['test_mail.mail_act_test_todo'], feedback=action_feedback)
|
||||
def action_close(self, action_feedback, attachment_ids=None):
|
||||
self.activity_feedback(['test_mail.mail_act_test_todo'],
|
||||
feedback=action_feedback,
|
||||
attachment_ids=attachment_ids)
|
||||
|
||||
|
||||
class MailTestTicket(models.Model):
|
||||
|
||||
Reference in New Issue
Block a user