From 023f4962f03395e058c8f6adf1e8a592dda2a20c Mon Sep 17 00:00:00 2001 From: Ronald Portier Date: Wed, 11 Apr 2018 01:02:39 +0200 Subject: [PATCH] [FIX] fetchnail_attach_from_folder. Can not pass object to action context. --- .../models/fetchmail_server_folder.py | 2 +- .../wizard/attach_mail_manually.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/fetchmail_attach_from_folder/models/fetchmail_server_folder.py b/fetchmail_attach_from_folder/models/fetchmail_server_folder.py index a238077ec..979fa1d2f 100644 --- a/fetchmail_attach_from_folder/models/fetchmail_server_folder.py +++ b/fetchmail_attach_from_folder/models/fetchmail_server_folder.py @@ -96,7 +96,7 @@ class FetchmailServerFolder(models.Model): 'type': 'ir.actions.act_window', 'res_model': 'fetchmail.attach.mail.manually', 'target': 'new', - 'context': dict(self.env.context, folder=self), + 'context': dict(self.env.context, folder_id=self.id), 'view_type': 'form', 'view_mode': 'form'} diff --git a/fetchmail_attach_from_folder/wizard/attach_mail_manually.py b/fetchmail_attach_from_folder/wizard/attach_mail_manually.py index e3100896d..5bdbe67d8 100644 --- a/fetchmail_attach_from_folder/wizard/attach_mail_manually.py +++ b/fetchmail_attach_from_folder/wizard/attach_mail_manually.py @@ -21,7 +21,10 @@ class AttachMailManually(models.TransientModel): def default_get(self, fields_list): defaults = super(AttachMailManually, self).default_get(fields_list) defaults['mail_ids'] = [] - folder = self.env.context.get('folder') + folder_model = self.env['fetchmail.server.folder'] + folder_id = self.env.context.get('folder_id') + defaults['folder_id'] = folder_id + folder = folder_model.browse([folder_id]) connection = folder.server_id.connect() connection.select(folder.path) criteria = 'FLAGGED' if folder.flag_nonmatching else 'UNDELETED' @@ -62,8 +65,10 @@ class AttachMailManually(models.TransientModel): result = super(AttachMailManually, self).fields_view_get( view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu) + folder_model = self.env['fetchmail.server.folder'] + folder_id = self.env.context.get('folder_id') + folder = folder_model.browse([folder_id]) tree = result['fields']['mail_ids']['views']['tree'] - folder = self.env.context.get('folder') tree['fields']['object_id']['selection'] = [ (folder.model_id.model, folder.model_id.name)] return result