[IMP] fetchmail: in config wizards, deactivate fetchmail servers when boolean option is unchecked
bzr revid: rco@openerp.com-20120625091951-udrlkq2ajamp13ff
This commit is contained in:
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user