0

when user MARK AS DONE or DONE & SCHEDULE NEXT a Schedule Activity i want to create a record in a custom model (table) through functions in mail.activity.

function name is action_done and action_done_schedule_next, if it success then required record should be created with below mentioned attributes from mail.activity. i want it because when a user marked activity as DONE, Odoo delete from activity and i want to check it, if its DONE then create next default sheduled activity. (if you have a better idea, please advise)

the fields required from mail.activity are: (please add fields which required necessarily for activity marked as DONE)

id, res_id, res_model, summary, write_date

my custom model (table) 'mail_activity_done' contains fields:

ma_id, ma_res_id, ma_res_model, ma_summary, ma_write_date

all types of DONE activity will be recorded here for later use. please help.

regards

Ahmed Haroon
  • 69
  • 1
  • 12

1 Answers1

0

in Odoo forum @Karak showed me to create record in my custom module as below:

class MailActivity(models.Model):
    _inherit = "mail.activity"

    def _action_done(self, feedback=False, attachmend_ids=None):
        messages, next_activities = super(MailActivity, self)._action_done(feedback, attachment_ids)

    # create records for custom model
    for activity in self:
        self.env["mail_activity_done"].create({
            'ma_id': activity.id,
            'ma_res_id': activity.res_id,
            'ma_res_model': activity.res_model,
            'ma_summary': activity.summary,
            'ma_write_date': activity.write_date})
    return messages, next_activities

if someone wants to create, can follow this one.

Ahmed Haroon
  • 69
  • 1
  • 12