[IMP] fetchmail config: remove fields from config wizards, and replace them by a button to open the fetchmail server form
bzr revid: rco@openerp.com-20120424095140-vn9e95sfn24iwkr7
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -10,15 +10,9 @@
|
||||
<field name="arch" type="xml">
|
||||
<group name="config_fetchmail" position="after">
|
||||
<field name="fetchmail_lead"/>
|
||||
<group colspan="2" attrs="{'invisible': [('fetchmail_lead','=',False)]}">
|
||||
<field name="lead_server" attrs="{'required': [('fetchmail_lead','=',True)]}"/>
|
||||
<field name="lead_type" on_change="onchange_fetchmail('lead', lead_type, lead_is_ssl)" attrs="{'required': [('fetchmail_lead','=',True)]}"/>
|
||||
<field name="lead_port" attrs="{'required': [('fetchmail_lead','=',True)]}"/>
|
||||
<field name="lead_is_ssl" on_change="onchange_fetchmail('lead', lead_type, lead_is_ssl)"/>
|
||||
<field name="lead_user" attrs="{'required': [('fetchmail_lead','=',True)]}"/>
|
||||
<field name="lead_password" password="True" attrs="{'required': [('fetchmail_lead','=',True)]}"/>
|
||||
<group colspan="2">
|
||||
<button type="object" name="configure_fetchmail_lead" string="Configure" icon="gtk-execute"/>
|
||||
</group>
|
||||
<newline/>
|
||||
</group>
|
||||
|
||||
<group name="config_crm" position="after">
|
||||
|
||||
@@ -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',
|
||||
}
|
||||
|
||||
@@ -11,15 +11,9 @@
|
||||
<field name="arch" type="xml">
|
||||
<group name="config_fetchmail" position="after">
|
||||
<field name="fetchmail_claim"/>
|
||||
<group colspan="2" attrs="{'invisible': [('fetchmail_claim','=',False)]}">
|
||||
<field name="claim_server" attrs="{'required': [('fetchmail_claim','=',True)]}"/>
|
||||
<field name="claim_type" on_change="onchange_fetchmail('claim', claim_type, claim_is_ssl)" attrs="{'required': [('fetchmail_claim','=',True)]}"/>
|
||||
<field name="claim_port" attrs="{'required': [('fetchmail_claim','=',True)]}"/>
|
||||
<field name="claim_is_ssl" on_change="onchange_fetchmail('claim', claim_type, claim_is_ssl)"/>
|
||||
<field name="claim_user" attrs="{'required': [('fetchmail_claim','=',True)]}"/>
|
||||
<field name="claim_password" password="True" attrs="{'required': [('fetchmail_claim','=',True)]}"/>
|
||||
<group colspan="2">
|
||||
<button type="object" name="configure_fetchmail_claim" string="Configure" icon="gtk-execute"/>
|
||||
</group>
|
||||
<newline/>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -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::
|
||||
|
||||
<field name="fetchmail_stuff"/>
|
||||
<button type="object" name="configure_fetchmail_stuff"/>
|
||||
|
||||
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:
|
||||
|
||||
@@ -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',
|
||||
}
|
||||
|
||||
|
||||
@@ -12,16 +12,9 @@
|
||||
<field name="module_document_ftp"/>
|
||||
<newline/>
|
||||
<field name="fetchmail_applicants"/>
|
||||
<group colspan="2" attrs="{'invisible': [('fetchmail_applicants','=',False)]}">
|
||||
<field name="applicants_server" attrs="{'required': [('fetchmail_applicants','=',True)]}"/>
|
||||
<field name="applicants_type" attrs="{'required': [('fetchmail_applicants','=',True)]}"
|
||||
on_change="onchange_fetchmail('applicants', applicants_type, applicants_is_ssl)"/>
|
||||
<field name="applicants_port" attrs="{'required': [('fetchmail_applicants','=',True)]}"/>
|
||||
<field name="applicants_is_ssl" attrs="{'required': [('fetchmail_applicants','=',True)]}"
|
||||
on_change="onchange_fetchmail('applicants', applicants_type, applicants_is_ssl)"/>
|
||||
<field name="applicants_user" attrs="{'required': [('fetchmail_applicants','=',True)]}"/>
|
||||
<field name="applicants_password" password="True" attrs="{'required': [('fetchmail_applicants','=',True)]}"/>
|
||||
</group>
|
||||
<group colspan="2">
|
||||
<button type="object" name="configure_fetchmail_applicants" string="Configure" icon="gtk-execute"/>
|
||||
</group>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -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',
|
||||
}
|
||||
|
||||
@@ -10,13 +10,8 @@
|
||||
<field name="arch" type="xml">
|
||||
<group name="support" position="after">
|
||||
<field name="fetchmail_issue"/>
|
||||
<group colspan="2" attrs="{'invisible': [('fetchmail_issue','=',False)]}">
|
||||
<field name="issue_server" attrs="{'required': [('fetchmail_issue','=',True)]}"/>
|
||||
<field name="issue_type" on_change="onchange_fetchmail('issue', issue_type, issue_is_ssl)" attrs="{'required': [('fetchmail_issue','=',True)]}"/>
|
||||
<field name="issue_port" attrs="{'required': [('fetchmail_issue','=',True)]}"/>
|
||||
<field name="issue_is_ssl" on_change="onchange_fetchmail('issue', issue_type, issue_is_ssl)"/>
|
||||
<field name="issue_user" attrs="{'required': [('fetchmail_issue','=',True)]}"/>
|
||||
<field name="issue_password" password="True" attrs="{'required': [('fetchmail_issue','=',True)]}"/>
|
||||
<group colspan="2">
|
||||
<button type="object" name="configure_fetchmail_issue" string="Configure" icon="gtk-execute"/>
|
||||
</group>
|
||||
</group>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user