Hi, I am trying to add a feature to require "Log Note", the internal note logged in the chatter, upon canceling 'stock.picking' record.
My code to override the original "action_cancel"
def action_cancel(self):
view = self.env.ref('mail.email_compose_message_wizard_form')
wiz = self.env['mail.compose.message'].create({'is_log': True})
_logger.info("Action Cancel is overrided.")
super(Picking, self).action_cancel()
return {
'name': _('Your Reason to Cancel?'),
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'mail.compose.message',
'views': [(view.id, 'form')],
'view_id': view.id,
'target': 'new',
'res_id': wiz.id,
'context': {},
}
It opens up the write wizard, but when I hit button 'Log', wizard closes but no note is logged in chatter.
Should I pass anything else through context?
I already tried
'context': {'active_model': self._name,
'active_id':self.id}
And also this in context.
'context': {'default_model': self._name,
'default_res_id':self.id}