[IMP,FIX]: Fixed problem of plugin installation. Improved fetchmail code.

bzr revid: uco@tinyerp.com-20120303071907-kk0942ijn0ztouak
This commit is contained in:
Ujjvala Collins (OpenERP) 2012-03-03 12:49:07 +05:30
parent 696681f571
commit 9c536a772c
7 changed files with 54 additions and 74 deletions

View File

@ -28,9 +28,7 @@ class crm_configuration(osv.osv_memory):
'module_crm_caldav' : fields.boolean("Caldav Synchronization",
help="""Allows Caldav features in Meeting, Share meeting with other calendar clients like sunbird.
It installs crm_caldav module."""),
'module_fetchmail_crm': fields.boolean("Lead/Opportunity mail gateway", help="""
Allows you to configure your incoming mail server. And creates leads for your mails.
It installs fetchmail_crm module."""),
'fetchmail_crm': fields.boolean("Lead/Opportunity mail gateway", help="Allows you to configure your incoming mail server. And creates leads for your mails."),
'server' : fields.char('Server Name', size=256),
'port' : fields.integer('Port'),
'type': fields.selection([
@ -68,36 +66,19 @@ class crm_configuration(osv.osv_memory):
Allows you to locate customer on Google Map.
It installs google_map module.
"""),
'module_plugin_thunderbird': fields.boolean('Thunderbird plugin',
help="""
The plugin allows you archive email and its attachments to the selected
OpenERP objects. You can select a partner, a task, a project, an analytical
account, or any other object and attach the selected mail as a .eml file in
the attachment of a selected record. You can create documents for CRM Lead,
HR Applicant and Project Issue from selected mails.
It installs plugin_thunderbird module.
"""),
'module_plugin_outlook': fields.boolean('Outlook plugin',
help="""
Outlook plug-in allows you to select an object that you would like to add
to your email and its attachments from MS Outlook. You can select a partner, a task,
a project, an analytical account, or any other object and archive selected
mail into mail.message with attachments.
It installs plugin_outlook module.
"""),
}
_defaults = {
'type': 'pop',
}
def create(self, cr, uid, vals, context=None):
ids = super(crm_configuration, self).create(cr, uid, vals, context=context)
self.execute(cr, uid, [ids], vals, context=context)
self.execute(cr, uid, [ids], vals, context)
return ids
def write(self, cr, uid, ids, vals, context=None):
self.execute(cr, uid, ids, vals, context=context)
self.execute(cr, uid, ids, vals, context)
return super(crm_configuration, self).write(cr, uid, ids, vals, context=context)
def execute(self, cr, uid, ids, vals, context=None):
@ -108,11 +89,13 @@ class crm_configuration(osv.osv_memory):
def get_default_email_configurations(self, cr, uid, ids, context=None):
ir_values_obj = self.pool.get('ir.values')
fetchmail_obj = self.pool.get('fetchmail.server')
result = {}
installed_modules = self.get_default_installed_modules(cr, uid, ids, context=context)
if 'module_fetchmail_crm' in installed_modules.keys():
for val in ir_values_obj.get(cr, uid, 'default', False, ['fetchmail.server']):
result.update({val[1]: val[2]})
server_ids = fetchmail_obj.search(cr, uid, [('name','=','Incoming Leads'),('state','=','done')])
if server_ids:
result.update({'fetchmail_crm': True})
for val in ir_values_obj.get(cr, uid, 'default', False, ['fetchmail.server']):
result.update({val[1]: val[2]})
return result
def onchange_server_type(self, cr, uid, ids, server_type=False, ssl=False):
@ -132,7 +115,7 @@ class crm_configuration(osv.osv_memory):
fetchmail_obj = self.pool.get('fetchmail.server')
ir_values_obj = self.pool.get('ir.values')
object_id = model_obj.search(cr, uid, [('model','=','crm.lead')])
if vals.get('module_fetchmail_crm') and object_id:
if vals.get('fetchmail_crm') and object_id:
fetchmail_vals = {
'name': 'Incoming Leads',
'object_id': object_id[0],
@ -143,9 +126,8 @@ class crm_configuration(osv.osv_memory):
'user': vals.get('user'),
'password': vals.get('password')
}
server_ids = fetchmail_obj.search(cr, uid, [])
installed_modules = self.get_default_installed_modules(cr, uid, ids, context=context)
if installed_modules.get('module_fetchmail_crm') or not server_ids:
server_ids = fetchmail_obj.search(cr, uid, [('name','=','Incoming Leads'),('state','!=','done')])
if not server_ids:
server_ids = [fetchmail_obj.create(cr, uid, fetchmail_vals, context=context)]
else:
server_ids = fetchmail_obj.search(cr, uid, [('name','=','Incoming Leads')], context=context)
@ -157,5 +139,10 @@ class crm_configuration(osv.osv_memory):
ir_values_obj.set(cr, uid, 'default', False, 'type', ['fetchmail.server'], fetchmail_vals.get('type'))
ir_values_obj.set(cr, uid, 'default', False, 'user', ['fetchmail.server'], fetchmail_vals.get('user'))
ir_values_obj.set(cr, uid, 'default', False, 'password', ['fetchmail.server'], fetchmail_vals.get('password'))
else:
server_ids = fetchmail_obj.search(cr, uid, [('name','=','Incoming Leads'),('state','=','done')])
fetchmail_obj.set_draft(cr, uid, server_ids, context=None)
crm_configuration()
crm_configuration()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -7,34 +7,24 @@
<field name="type">form</field>
<field name="inherit_id" ref="base.res_config_view_for_all"/>
<field name="arch" type="xml">
<group name="crm" position="inside">
<group col="8" colspan="4" name="emails">
<group col="4" colspan="2">
<separator string="Plugins" colspan="4"/>
<newline/>
<field name="module_plugin_thunderbird" colspan="2"/>
<newline/>
<field name="module_plugin_outlook" colspan="2"/>
<newline/>
</group>
<group col="4" colspan="2">
<separator string="Emails" colspan="4"/>
<field name="module_fetchmail_crm"/>
<newline/>
<group col="4" colspan="2"
attrs="{'invisible': [('module_fetchmail_crm','=',False)]}">
<field name="server" attrs="{'required': [('module_fetchmail_crm','=',True)]}"/>
<field name="type" nolabel="1" on_change="onchange_server_type(type, is_ssl)" attrs="{'required': [('module_fetchmail_crm','=',True)]}"/>
<field name="port" attrs="{'required': [('module_fetchmail_crm','=',True)]}"/>
<field name="is_ssl" on_change="onchange_server_type(type, is_ssl)"/>
<newline/>
<field name="user" attrs="{'required': [('module_fetchmail_crm','=',True)]}"/>
<field name="password" password="True" attrs="{'required': [('module_fetchmail_crm','=',True)]}"/>
</group>
</group>
</group>
<xpath expr="//form/group[@name='crm']/group[@name='plugin']" position="inside">
<group col="2" colspan="2" name="emails">
<separator string="Emails" colspan="2"/>
<field name="fetchmail_crm"/>
<newline/>
<group col="4" colspan="2" attrs="{'invisible': [('fetchmail_crm','=',False)]}">
<field name="server" attrs="{'required': [('fetchmail_crm','=',True)]}"/>
<field name="type" nolabel="1" on_change="onchange_server_type(type, is_ssl)" attrs="{'required': [('fetchmail_crm','=',True)]}"/>
<field name="port" attrs="{'required': [('fetchmail_crm','=',True)]}"/>
<field name="is_ssl" on_change="onchange_server_type(type, is_ssl)"/>
<newline/>
<field name="user" attrs="{'required': [('fetchmail_crm','=',True)]}"/>
<field name="password" password="True" attrs="{'required': [('fetchmail_crm','=',True)]}"/>
</group>
</group>
</xpath>
<xpath expr="//form/group[@name='crm']/group[@name='plugin']" position="after">
<group colspan="4" col="4" name="synchronization">
<separator string="Import and Synchronize data from an other application" colspan="4"/>
<group colspan="2" col="2">
@ -59,7 +49,7 @@
<field name="module_google_map"/>
</group>
</group>
</group>
</xpath>
</field>
</record>

View File

@ -23,6 +23,7 @@ import mail_message
import mail_thread
import res_partner
import wizard
import res_config
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -62,6 +62,7 @@ The main features are:
"res_partner_view.xml",
'security/ir.model.access.csv',
'mail_data.xml',
'res_config_view.xml',
],
'installable': True,
'auto_install': False,

View File

@ -48,18 +48,18 @@
<field name="target">new</field>
</record>
<!-- NEED TO BE IMPROVED -->
<!--record id="view_config_outlook_installer" model="ir.ui.view">
<!-- Sales Configuration -->
<record id="view_config_outlook_installer" model="ir.ui.view">
<field name="name">Sales Application</field>
<field name="model">res.config</field>
<field name="type">form</field>
<field name="inherit_id" ref="base.res_config_view_for_all"/>
<field name="inherit_id" ref="mail.view_sales_config_plugin"/>
<field name="arch" type="xml">
<field name="module_plugin_outlook" position="after">
<button name="%(action_outlook_installer)d" type="action" string="Configure" icon="gtk-execute"/>
<button name="%(action_outlook_installer)d" type="action" string="Configure Outlook" icon="gtk-execute"/>
</field>
</field>
</record-->
</record>
<record id="action_outlook_wizard" model="ir.actions.act_window">
<field name="name">Install Outlook Plug-In</field>

View File

@ -54,19 +54,19 @@
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<!-- NEED TO BE IMPROVED -->
<!--record id="view_config_thunderbird_installer" model="ir.ui.view">
<!-- Sales Configuration -->
<record id="view_config_thunderbird_installer" model="ir.ui.view">
<field name="name">Sales Application</field>
<field name="model">res.config</field>
<field name="type">form</field>
<field name="inherit_id" ref="base.res_config_view_for_all"/>
<field name="inherit_id" ref="mail.view_sales_config_plugin"/>
<field name="arch" type="xml">
<field name="module_plugin_thunderbird" position="after">
<button name="%(action_thunderbird_installer)d" type="action" string="Configure" icon="gtk-execute"/>
<button name="%(action_thunderbird_installer)d" type="action" string="Configure Thunderbird" icon="gtk-execute"/>
</field>
</field>
</record-->
</record>
<menuitem id="base.menu_base_config_plugins" name="Plugins" parent="base.menu_base_config" sequence="10"/>
<menuitem id="menu_base_config_plugins_thunderbird" action="action_thunderbird_installer" parent="base.menu_base_config_plugins" sequence="10"/>

View File

@ -81,6 +81,7 @@ class sale_configuration(osv.osv_memory):
installed_modules = super(sale_configuration, self).get_default_installed_modules(cr, uid, ids, context=context)
if installed_modules.get('module_project_mrp') and installed_modules.get('module_project_timesheet'):
installed_modules['task_work'] = True
if installed_modules.get('module_account_analytic_analysis'):
prod_id = data_obj.get_object(cr, uid, 'product', 'product_consultant').id
uom_id = self.pool.get('product.product').browse(cr, uid, prod_id).uom_id.id
installed_modules.update({'time_unit': uom_id})
@ -111,11 +112,11 @@ class sale_configuration(osv.osv_memory):
def create(self, cr, uid, vals, context=None):
ids = super(sale_configuration, self).create(cr, uid, vals, context=context)
self.execute(cr, uid, [ids], vals, context=context)
self.execute(cr, uid, [ids], vals, context)
return ids
def write(self, cr, uid, ids, vals, context=None):
self.execute(cr, uid, ids, vals, context=context)
self.execute(cr, uid, ids, vals, context)
return super(sale_configuration, self).write(cr, uid, ids, vals, context=context)
def execute(self, cr, uid, ids, vals, context=None):