From 31bc158635ea908b9973ad7d77cf74a4f4046dae Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Mon, 25 Jun 2012 11:19:51 +0200 Subject: [IMP] fetchmail: in config wizards, deactivate fetchmail servers when boolean option is unchecked bzr revid: rco@openerp.com-20120625091951-udrlkq2ajamp13ff --- addons/fetchmail/res_config.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'addons/fetchmail/res_config.py') diff --git a/addons/fetchmail/res_config.py b/addons/fetchmail/res_config.py index f7dade6ae33..6655b95ac0e 100644 --- a/addons/fetchmail/res_config.py +++ b/addons/fetchmail/res_config.py @@ -32,7 +32,7 @@ class fetchmail_config_settings(osv.osv_memory): _inherit = ['res.config.settings', 'fetchmail.config.settings'] _columns = { - 'fetchmail_stuff': fields.boolean(..., readonly=True, + 'fetchmail_stuff': fields.boolean(..., fetchmail_model='my.stuff', fetchmail_name='Incoming Stuff'), } @@ -67,6 +67,18 @@ class fetchmail_config_settings(osv.osv_memory): res[f] = bool(server_ids) return res + def set_fetchmail(self, cr, uid, ids, context=None): + """ deactivate fetchmail servers for all fields like 'fetchmail_XXX' that are False """ + config = self.browse(cr, uid, ids[0], context) + fetchmail_fields = [f for f in self._columns if f.startswith('fetchmail_')] + # determine which models should not have active fetchmail servers, and + # deactivate all active servers for those models + models = [self._columns[f].fetchmail_model for f in fetchmail_fields if not config[f]] + if models: + fetchmail_server = self.pool.get('fetchmail.server') + server_ids = fetchmail_server.search(cr, uid, [('object_id.model', 'in', models), ('state', '=', 'done')]) + fetchmail_server.set_draft(cr, uid, server_ids, context) + def configure_fetchmail(self, cr, uid, field, context=None): """ open the form view of the fetchmail.server to configure """ action = { -- cgit v1.2.3 From 863a810f1580cfdf7b698cb8698fc30759af6da6 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Fri, 29 Jun 2012 15:41:51 +0200 Subject: [FIX] base_setup, fetchmail: add target in action methods opening a form view bzr revid: rco@openerp.com-20120629134151-oqharq4xhylq3fze --- addons/fetchmail/res_config.py | 1 + 1 file changed, 1 insertion(+) (limited to 'addons/fetchmail/res_config.py') diff --git a/addons/fetchmail/res_config.py b/addons/fetchmail/res_config.py index 6655b95ac0e..f2447ce7b94 100644 --- a/addons/fetchmail/res_config.py +++ b/addons/fetchmail/res_config.py @@ -85,6 +85,7 @@ class fetchmail_config_settings(osv.osv_memory): 'type': 'ir.actions.act_window', 'res_model': 'fetchmail.server', 'view_mode': 'form', + 'target': 'current', } model_name = self._columns[field].fetchmail_model model_id = self.pool.get('ir.model').search(cr, uid, [('model', '=', model_name)])[0] -- cgit v1.2.3