Browse Source

[FIX] fetchnail_attach_from_folder. Can not pass object to action context.

pull/1317/merge
Ronald Portier 7 years ago
committed by Holger Brunn
parent
commit
023f4962f0
  1. 2
      fetchmail_attach_from_folder/models/fetchmail_server_folder.py
  2. 9
      fetchmail_attach_from_folder/wizard/attach_mail_manually.py

2
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'}

9
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

Loading…
Cancel
Save