From a8954c2114932980965709860d064b5a15278ba5 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Thu, 16 Jul 2015 11:21:42 +0200 Subject: [PATCH 1/2] [FIX] honor sequence --- fetchmail_attach_from_folder/model/fetchmail_server_folder.py | 1 + fetchmail_attach_from_folder/view/fetchmail_server.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/fetchmail_attach_from_folder/model/fetchmail_server_folder.py b/fetchmail_attach_from_folder/model/fetchmail_server_folder.py index 570245572..2d1b2d2c3 100644 --- a/fetchmail_attach_from_folder/model/fetchmail_server_folder.py +++ b/fetchmail_attach_from_folder/model/fetchmail_server_folder.py @@ -26,6 +26,7 @@ from .. import match_algorithm class fetchmail_server_folder(models.Model): _name = 'fetchmail.server.folder' _rec_name = 'path' + _order = 'sequence' def _get_match_algorithms(self): def get_all_subclasses(cls): diff --git a/fetchmail_attach_from_folder/view/fetchmail_server.xml b/fetchmail_attach_from_folder/view/fetchmail_server.xml index 3d58421e7..c2a15fd87 100644 --- a/fetchmail_attach_from_folder/view/fetchmail_server.xml +++ b/fetchmail_attach_from_folder/view/fetchmail_server.xml @@ -17,7 +17,7 @@ nolabel="1" on_change="onchange_server_type(type, is_ssl, object_id)"> - + From d26eb82516d98e3fd978b94d7cb1b7d2f87f844f Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Thu, 16 Jul 2015 11:32:08 +0200 Subject: [PATCH 2/2] [ADD] allow to deactivate folders --- fetchmail_attach_from_folder/model/fetchmail_server.py | 7 ++++--- .../model/fetchmail_server_folder.py | 2 ++ fetchmail_attach_from_folder/view/fetchmail_server.xml | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/fetchmail_attach_from_folder/model/fetchmail_server.py b/fetchmail_attach_from_folder/model/fetchmail_server.py index e01ea7779..fc6c709f3 100644 --- a/fetchmail_attach_from_folder/model/fetchmail_server.py +++ b/fetchmail_attach_from_folder/model/fetchmail_server.py @@ -33,7 +33,8 @@ class fetchmail_server(models.Model): _inherit = 'fetchmail.server' folder_ids = fields.One2many( - 'fetchmail.server.folder', 'server_id', 'Folders') + 'fetchmail.server.folder', 'server_id', 'Folders', + context={'active_test': False}) object_id = fields.Many2one(required=False) _defaults = { @@ -67,7 +68,7 @@ class fetchmail_server(models.Model): }) connection = this.connect() - for folder in this.folder_ids: + for folder in this.folder_ids.filtered('active'): this.handle_folder(connection, folder) connection.close() @@ -216,7 +217,7 @@ class fetchmail_server(models.Model): this.write({'state': 'draft'}) connection = this.connect() connection.select() - for folder in this.folder_ids: + for folder in this.folder_ids.filtered('active'): if connection.select(folder.path)[0] != 'OK': raise exceptions.ValidationError( _('Mailbox %s not found!') % folder.path) diff --git a/fetchmail_attach_from_folder/model/fetchmail_server_folder.py b/fetchmail_attach_from_folder/model/fetchmail_server_folder.py index 2d1b2d2c3..7ea7ef3bb 100644 --- a/fetchmail_attach_from_folder/model/fetchmail_server_folder.py +++ b/fetchmail_attach_from_folder/model/fetchmail_server_folder.py @@ -94,10 +94,12 @@ class fetchmail_server_folder(models.Model): 'Message state', help='The state messages fetched from this folder should be ' 'assigned in Odoo') + active = fields.Boolean('Active') _defaults = { 'flag_nonmatching': True, 'msg_state': 'received', + 'active': True, } @api.multi diff --git a/fetchmail_attach_from_folder/view/fetchmail_server.xml b/fetchmail_attach_from_folder/view/fetchmail_server.xml index c2a15fd87..e5160cc8a 100644 --- a/fetchmail_attach_from_folder/view/fetchmail_server.xml +++ b/fetchmail_attach_from_folder/view/fetchmail_server.xml @@ -16,7 +16,8 @@ name="folder_ids" nolabel="1" on_change="onchange_server_type(type, is_ssl, object_id)"> - + + @@ -37,6 +38,7 @@ +