diff --git a/addons/crm/res_config.py b/addons/crm/res_config.py
index b4a9e368d4c..962eccece83 100644
--- a/addons/crm/res_config.py
+++ b/addons/crm/res_config.py
@@ -26,23 +26,12 @@ class crm_configuration(osv.osv_memory):
_inherit = ['sale.config.settings', 'fetchmail.config.settings']
_columns = {
+ 'fetchmail_lead': fields.boolean("Create Leads from Incoming Mails", readonly=True,
+ fetchmail_model='crm.lead', fetchmail_name='Incoming Leads',
+ help="""Allows you to configure your incoming mail server, and create leads from incoming emails."""),
'module_crm_caldav': fields.boolean("Caldav Synchronization",
help="""Use protocol caldav to synchronize meetings with other calendar applications (like Sunbird).
This installs the module crm_caldav."""),
- 'fetchmail_lead': fields.boolean("Create leads from an email account",
- fetchmail_model='crm.lead', fetchmail_name='Incoming leads',
- help="""Allows you to configure your incoming mail server, and create leads from incoming emails."""),
- 'lead_server': fields.char('Server', size=256),
- 'lead_port': fields.integer('Port'),
- 'lead_type': fields.selection([
- ('pop', 'POP Server'),
- ('imap', 'IMAP Server'),
- ('local', 'Local Server'),
- ], 'Type'),
- 'lead_is_ssl': fields.boolean('SSL/TLS',
- help="Connections are encrypted with SSL/TLS through a dedicated port (default: IMAPS=993, POP=995)"),
- 'lead_user': fields.char('Username', size=256),
- 'lead_password': fields.char('Password', size=1024),
'module_import_sugarcrm': fields.boolean("SugarCRM Import",
help="""Import SugarCRM leads, opportunities, users, accounts, contacts, employees, meetings, phonecalls, emails, project and project tasks data.
This installs the module import_sugarcrm."""),
@@ -57,8 +46,4 @@ class crm_configuration(osv.osv_memory):
This installs the module google_map."""),
}
- _defaults = {
- 'lead_type': 'pop',
- }
-
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/crm/res_config_view.xml b/addons/crm/res_config_view.xml
index 9184eff5153..12bd97ff1ff 100644
--- a/addons/crm/res_config_view.xml
+++ b/addons/crm/res_config_view.xml
@@ -10,15 +10,9 @@
-
-
-
-
-
-
-
+
+
-
diff --git a/addons/crm_claim/res_config.py b/addons/crm_claim/res_config.py
index 73a6680663d..0dca243890b 100644
--- a/addons/crm_claim/res_config.py
+++ b/addons/crm_claim/res_config.py
@@ -26,21 +26,7 @@ class crm_claim_settings(osv.osv_memory):
_inherit = ['sale.config.settings', 'fetchmail.config.settings']
_columns = {
- 'fetchmail_claim': fields.boolean("Create claims from an email account",
- fetchmail_model='crm.claim', fetchmail_name='Incoming claims',
+ 'fetchmail_claim': fields.boolean("Create Claims from Incoming Mails", readonly=True,
+ fetchmail_model='crm.claim', fetchmail_name='Incoming Claims',
help="""Allows you to configure your incoming mail server, and create claims from incoming emails."""),
- 'claim_server' : fields.char('Server', size=256),
- 'claim_port' : fields.integer('Port'),
- 'claim_type': fields.selection([
- ('pop', 'POP Server'),
- ('imap', 'IMAP Server'),
- ('local', 'Local Server'),
- ], 'Type'),
- 'claim_is_ssl': fields.boolean('SSL/TLS', help="Connections are encrypted with SSL/TLS through a dedicated port (default: IMAPS=993, POP=995)"),
- 'claim_user' : fields.char('Username', size=256),
- 'claim_password' : fields.char('Password', size=1024),
- }
-
- _defaults = {
- 'claim_type': 'pop',
}
diff --git a/addons/crm_claim/res_config_view.xml b/addons/crm_claim/res_config_view.xml
index c6c66290303..46a4d4ff690 100644
--- a/addons/crm_claim/res_config_view.xml
+++ b/addons/crm_claim/res_config_view.xml
@@ -11,15 +11,9 @@
-
-
-
-
-
-
-
+
+
-
diff --git a/addons/fetchmail/res_config.py b/addons/fetchmail/res_config.py
index 2b4072a63c3..f7dade6ae33 100644
--- a/addons/fetchmail/res_config.py
+++ b/addons/fetchmail/res_config.py
@@ -25,99 +25,72 @@ class fetchmail_config_settings(osv.osv_memory):
""" This wizard can be inherited in conjunction with 'res.config.settings', in order to
define fields that configure a fetchmail server.
- It relies on the following convention on a set of fields::
+ It relies on the following convention on the object::
- class my_config_wizard(osv.osv_memory):
+ class my_config_settings(osv.osv_memory):
_name = 'my.settings'
- _inherits = ['res.config.settings', 'fetchmail.config.settings']
+ _inherit = ['res.config.settings', 'fetchmail.config.settings']
_columns = {
- 'fetchmail_X': fields.boolean(..., fetchmail_model='my.model', fetchmail_name='Blah'),
- 'X_server': fields.char('Server Name', size=256),
- 'X_port': fields.integer('Port'),
- 'X_type': fields.selection(
- [('pop', 'POP Server'), ('imap', 'IMAP Server'), ('local', 'Local Server')],
- 'Server Type'),
- 'X_is_ssl': fields.boolean('SSL/TLS'),
- 'X_user': fields.char('Username', size=256),
- 'X_password': fields.char('Password', size=1024),
+ 'fetchmail_stuff': fields.boolean(..., readonly=True,
+ fetchmail_model='my.stuff', fetchmail_name='Incoming Stuff'),
}
- The method ``get_default_fetchmail_servers`` retrieves the current fetchmail configuration
- for all fields that start with 'fetchmail_'. It looks up configurations that match the
- given model name (``fetchmail_model``). The method ``set_fetchmail_servers`` updates the
- fetchmail configurations by following the same conventions. Both methods are called
- automatically by the methods of the model 'res.config.settings'.
+ def configure_fetchmail_stuff(self, cr, uid, ids, context=None):
+ return self.configure_fetchmail(cr, uid, 'fetchmail_stuff', context)
- The onchange method ``onchange_fetchmail`` can be used to react on changes on the fields
- 'X_type' and 'X_is_ssl'. Its first parameter is the fields' prefix (here 'X').
+ and in the form view::
+
+
+
+
+ The method ``get_default_fetchmail`` determines the value of all fields that start
+ with 'fetchmail_'. It looks up fetchmail server configurations that match the given
+ model name (``fetchmail_model``) and are active.
+
+ The button action ``configure_fetchmail_stuff`` is caught by the object, and calls
+ automatically the method ``configure_fetchmail``; it opens the fetchmail server
+ configuration form for the corresponding field.
"""
_name = 'fetchmail.config.settings'
- def get_default_fetchmail_servers(self, cr, uid, fields, context=None):
+ def get_default_fetchmail(self, cr, uid, fields, context=None):
+ """ determine the value of all fields like 'fetchmail_XXX' """
ir_model = self.pool.get('ir.model')
fetchmail_server = self.pool.get('fetchmail.server')
- fetchmail_fields = [f for f in self._columns if f.startswith('fetchmail_')]
+ fetchmail_fields = [f for f in fields if f.startswith('fetchmail_')]
res = {}
- for field in fetchmail_fields:
- model_name = self._columns[field].fetchmail_model
+ for f in fetchmail_fields:
+ model_name = self._columns[f].fetchmail_model
model_id = ir_model.search(cr, uid, [('model', '=', model_name)])[0]
server_ids = fetchmail_server.search(cr, uid, [('object_id', '=', model_id), ('state', '=', 'done')])
- if server_ids:
- server = fetchmail_server.browse(cr, uid, server_ids[0], context)
- prefix = field[10:]
- res.update({
- field: True,
- prefix + '_server': server.server,
- prefix + '_port': server.port,
- prefix + '_type': server.type,
- prefix + '_is_ssl': server.is_ssl,
- prefix + '_user': server.user,
- prefix + '_password': server.password,
- })
+ res[f] = bool(server_ids)
return res
- def set_fetchmail_servers(self, cr, uid, ids, context):
- ir_model = self.pool.get('ir.model')
- fetchmail_server = self.pool.get('fetchmail.server')
- fetchmail_fields = [f for f in self._columns if f.startswith('fetchmail_')]
- config = self.browse(cr, uid, ids[0], context)
- for field in fetchmail_fields:
- model_name = self._columns[field].fetchmail_model
- model_id = ir_model.search(cr, uid, [('model', '=', model_name)])[0]
- server_ids = fetchmail_server.search(cr, uid, [('object_id', '=', model_id), ('state', '=', 'done')])
- if config[field]:
- prefix = field[10:]
- values = {
- 'server': config[prefix + '_server'],
- 'port': config[prefix + '_port'],
- 'type': config[prefix + '_type'],
- 'is_ssl': config[prefix + '_is_ssl'],
- 'user': config[prefix + '_user'],
- 'password': config[prefix + '_password'],
- }
- if not server_ids:
- values.update({
- 'name': getattr(self._columns[field], 'fetchmail_name', model_name),
- 'object_id': model_id,
- })
- server_ids = [fetchmail_server.create(cr, uid, values, context=context)]
- else:
- server_ids = fetchmail_server.search(cr, uid, [('object_id', '=', model_id)], context=context)
- fetchmail_server.write(cr, uid, server_ids, values, context=context)
- fetchmail_server.button_confirm_login(cr, uid, server_ids, context)
- else:
- fetchmail_server.set_draft(cr, uid, server_ids, context)
-
- def onchange_fetchmail(self, cr, uid, ids, prefix, server_type, ssl, context=None):
- values = {}
- if server_type == 'pop':
- values[prefix + '_port'] = ssl and 995 or 110
- elif server_type == 'imap':
- values[prefix + '_port'] = ssl and 993 or 143
+ def configure_fetchmail(self, cr, uid, field, context=None):
+ """ open the form view of the fetchmail.server to configure """
+ action = {
+ 'type': 'ir.actions.act_window',
+ 'res_model': 'fetchmail.server',
+ 'view_mode': 'form',
+ }
+ model_name = self._columns[field].fetchmail_model
+ model_id = self.pool.get('ir.model').search(cr, uid, [('model', '=', model_name)])[0]
+ server_ids = self.pool.get('fetchmail.server').search(cr, uid, [('object_id', '=', model_id)])
+ if server_ids:
+ action['res_id'] = server_ids[0]
else:
- values[prefix + '_server'] = False
- values[prefix + '_port'] = 0
- return {'value': values}
+ action['context'] = {
+ 'default_name': self._columns[field].fetchmail_name,
+ 'default_object_id': model_id,
+ }
+ return action
+
+ def __getattr__(self, name):
+ """ catch calls to 'configure_fetchmail_XXX' """
+ if name.startswith('configure_fetchmail_'):
+ return (lambda cr, uid, ids, context=None:
+ self.configure_fetchmail(cr, uid, name[10:], context))
+ return super(fetchmail_config_settings, self).__getattr__(name)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/hr_recruitment/res_config.py b/addons/hr_recruitment/res_config.py
index 2afec802689..eeb36b60ae7 100644
--- a/addons/hr_recruitment/res_config.py
+++ b/addons/hr_recruitment/res_config.py
@@ -29,24 +29,9 @@ class hr_applicant_settings(osv.osv_memory):
'module_document_ftp': fields.boolean('Index & Track Documents',
help="""Manage your CV's and motivation letter related to all applicants.
This installs the module document_ftp."""),
- 'fetchmail_applicants': fields.boolean('Create Applicants from an Email Account',
+ 'fetchmail_applicants': fields.boolean('Create Applicants from Incoming Mails', readonly=True,
fetchmail_model='hr.applicant', fetchmail_name='Incoming HR Applications',
help ="""Allow applicants to send their job application to an email address (jobs@mycompany.com),
and create automatically application documents in the system."""),
- 'applicants_server': fields.char('Server', size=256),
- 'applicants_port': fields.integer('Port'),
- 'applicants_type': fields.selection([
- ('pop', 'POP Server'),
- ('imap', 'IMAP Server'),
- ('local', 'Local Server'),
- ], 'Type'),
- 'applicants_is_ssl': fields.boolean('SSL/TLS',
- help="Connections are encrypted with SSL/TLS through a dedicated port (default: IMAPS=993, POP=995)"),
- 'applicants_user': fields.char('Username', size=256),
- 'applicants_password': fields.char('Password', size=1024),
- }
-
- _defaults = {
- 'applicants_type': 'pop',
}
diff --git a/addons/hr_recruitment/res_config_view.xml b/addons/hr_recruitment/res_config_view.xml
index 32575a4726d..c6015198c8e 100644
--- a/addons/hr_recruitment/res_config_view.xml
+++ b/addons/hr_recruitment/res_config_view.xml
@@ -12,16 +12,9 @@
-
-
-
-
-
-
-
-
+
+
+
diff --git a/addons/project_issue/res_config.py b/addons/project_issue/res_config.py
index 1944444923a..21e50b21e8d 100644
--- a/addons/project_issue/res_config.py
+++ b/addons/project_issue/res_config.py
@@ -26,21 +26,7 @@ class project_issue_settings(osv.osv_memory):
_inherit = ['project.config.settings', 'fetchmail.config.settings']
_columns = {
- 'fetchmail_issue': fields.boolean("Create issues from an email account",
- fetchmail_model='project.issue', fetchmail_name='Incoming issues',
+ 'fetchmail_issue': fields.boolean("Create Issues from Incoming Mails", readonly=True,
+ fetchmail_model='project.issue', fetchmail_name='Incoming Issues',
help="""Allows you to configure your incoming mail server, and create issues from incoming emails."""),
- 'issue_server' : fields.char('Server', size=256),
- 'issue_port' : fields.integer('Port'),
- 'issue_type': fields.selection([
- ('pop', 'POP Server'),
- ('imap', 'IMAP Server'),
- ('local', 'Local Server'),
- ], 'Type'),
- 'issue_is_ssl': fields.boolean('SSL/TLS', help="Connections are encrypted with SSL/TLS through a dedicated port (default: IMAPS=993, POP=995)"),
- 'issue_user' : fields.char('Username', size=256),
- 'issue_password' : fields.char('Password', size=1024),
- }
-
- _defaults = {
- 'issue_type': 'pop',
}
diff --git a/addons/project_issue/res_config_view.xml b/addons/project_issue/res_config_view.xml
index d2cc501bc96..6b2ef4c56a2 100644
--- a/addons/project_issue/res_config_view.xml
+++ b/addons/project_issue/res_config_view.xml
@@ -10,13 +10,8 @@
-
-
-
-
-
-
-
+
+