[MERGE] fix of outlook plugin. It's now working with outlook 2010 (not yet with 2013, the work is still in progress for that version)

bzr revid: qdp-launchpad@openerp.com-20130325092738-gfskosss5xs8jffj
This commit is contained in:
Quentin (OpenERP) 2013-03-25 10:27:38 +01:00
commit 927c9ee432
7 changed files with 41 additions and 34 deletions

View File

@ -4,7 +4,8 @@ Created on 18 oct. 2011
@author: openerp @author: openerp
''' '''
from openerp.osv import fields, osv from openerp.osv import osv
from openerp.tools.translate import _
class plugin_handler(osv.osv_memory): class plugin_handler(osv.osv_memory):
_name = 'plugin.handler' _name = 'plugin.handler'
@ -29,7 +30,7 @@ class plugin_handler(osv.osv_memory):
partner_ids = partner_obj.search(cr, uid, [('email', 'like', address_email)]) partner_ids = partner_obj.search(cr, uid, [('email', 'like', address_email)])
res_id = partner_ids and partner_ids[0] or 0 res_id = partner_ids and partner_ids[0] or 0
url = self._make_url(cr, uid, res_id, 'res.partner') url = self._make_url(cr, uid, res_id, 'res.partner')
return ('res.partner', res_id , url) return ('res.partner', res_id, url)
def document_get(self, cr, uid, email): def document_get(self, cr, uid, email):
""" """
@ -48,7 +49,7 @@ class plugin_handler(osv.osv_memory):
message_id = msg.get('message_id') message_id = msg.get('message_id')
msg_id = False msg_id = False
if message_id: if message_id:
msg_ids = mail_message_obj.search(cr, uid, [('message_id','=', message_id)]) msg_ids = mail_message_obj.search(cr, uid, [('message_id', '=', message_id)])
msg_id = len(msg_ids) and msg_ids[0] or False msg_id = len(msg_ids) and msg_ids[0] or False
if not msg_id and parent_id: if not msg_id and parent_id:
msg_id = parent_id msg_id = parent_id
@ -57,8 +58,8 @@ class plugin_handler(osv.osv_memory):
res_id = msg.res_id res_id = msg.res_id
model = msg.model model = msg.model
url = self._make_url(cr, uid, res_id, model) url = self._make_url(cr, uid, res_id, model)
name = self.pool.get(model).name_get(cr, uid, [res_id])[0][1] name = self.pool.get(model).name_get(cr, uid, [res_id])[0][1]
return (model,res_id, url,name) return (model, res_id, url, name)
def document_type(self, cr, uid, context=None): def document_type(self, cr, uid, context=None):
""" """
@ -94,26 +95,25 @@ class plugin_handler(osv.osv_memory):
model_obj = self.pool.get(model) model_obj = self.pool.get(model)
msg = self.pool.get('mail.thread').message_parse(cr, uid, email) msg = self.pool.get('mail.thread').message_parse(cr, uid, email)
message_id = msg.get('message-id') message_id = msg.get('message-id')
mail_ids = mail_message.search(cr, uid, [('message_id','=',message_id),('res_id','=',res_id),('model','=',model)]) mail_ids = mail_message.search(cr, uid, [('message_id', '=', message_id), ('res_id', '=', res_id), ('model', '=', model)])
if message_id and mail_ids:
if message_id and mail_ids :
mail_record = mail_message.browse(cr, uid, mail_ids)[0] mail_record = mail_message.browse(cr, uid, mail_ids)[0]
res_id = mail_record.res_id res_id = mail_record.res_id
notify = "Email already pushed" notify = _("Email already pushed")
elif res_id == 0: elif res_id == 0:
if model == 'res.partner': if model == 'res.partner':
notify = 'User the Partner button to create a new partner' notify = _('Use the Partner button to create a new partner')
else: else:
res_id = model_obj.message_process(cr, uid, model, email) res_id = model_obj.message_process(cr, uid, model, email)
notify = "Mail successfully pushed, a new %s has been created " % model notify = _("Mail successfully pushed, a new %s has been created.") % model
else: else:
model_obj.message_post(cr, uid, [res_id], model_obj.message_post(cr, uid, [res_id],
body= msg.get('body'), body=msg.get('body'),
subject= msg.get('subject'), subject=msg.get('subject'),
type= 'email', type='email',
parent_id= msg.get('parent_id'), parent_id=msg.get('parent_id'),
attachments= msg.get('attachments')) attachments=msg.get('attachments'))
notify = "Mail successfully pushed" notify = _("Mail successfully pushed")
url = self._make_url(cr, uid, res_id, model) url = self._make_url(cr, uid, res_id, model)
return (model, res_id, url, notify) return (model, res_id, url, notify)
@ -154,16 +154,17 @@ class plugin_handler(osv.osv_memory):
message_id = msg.get('message-id') message_id = msg.get('message-id')
push_mail = self.push_message(cr, uid, model, headers, res_id) push_mail = self.push_message(cr, uid, model, headers, res_id)
res_id = push_mail[1] res_id = push_mail[1]
model = push_mail[0] model = push_mail[0]
notify = push_mail[3]
for name in attachments.keys(): for name in attachments.keys():
attachment_ids = ir_attachment_obj.search(cr, uid, [('res_model', '=', model), ('res_id', '=', res_id), ('datas_fname', '=', name)]) attachment_ids = ir_attachment_obj.search(cr, uid, [('res_model', '=', model), ('res_id', '=', res_id), ('datas_fname', '=', name)])
if attachment_ids: if attachment_ids:
attach_ids.append( attachment_ids[0]) attach_ids.append(attachment_ids[0])
else: else:
vals = {"res_model": model, "res_id": res_id, "name": name, "datas" :attachments[name], "datas_fname" : name} vals = {"res_model": model, "res_id": res_id, "name": name, "datas": attachments[name], "datas_fname": name}
attach_ids.append(ir_attachment_obj.create(cr, uid, vals)) attach_ids.append(ir_attachment_obj.create(cr, uid, vals))
mail_ids = mail_message.search(cr, uid, [('message_id','=',message_id),('res_id','=',res_id),('model','=',model)]) mail_ids = mail_message.search(cr, uid, [('message_id', '=', message_id), ('res_id', '=', res_id), ('model', '=', model)])
if mail_ids: if mail_ids:
ids = mail_message.write(cr, uid, mail_ids[0], { 'attachment_ids': [(6, 0, attach_ids)],'body':body,'body_html':body_html}) mail_message.write(cr, uid, mail_ids[0], {'attachment_ids': [(6, 0, attach_ids)], 'body': body, 'body_html': body_html})
url = self._make_url(cr, uid, res_id, model) url = self._make_url(cr, uid, res_id, model)
return (model, res_id, url) return (model, res_id, url, notify)

View File

@ -17,6 +17,7 @@
<UpgradeBackupLocation> <UpgradeBackupLocation>
</UpgradeBackupLocation> </UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion> <OldToolsVersion>3.5</OldToolsVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl> <PublishUrl>publish\</PublishUrl>
<Install>true</Install> <Install>true</Install>
<InstallFrom>Disk</InstallFrom> <InstallFrom>Disk</InstallFrom>
@ -29,7 +30,6 @@
<MapFileExtensions>true</MapFileExtensions> <MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision> <ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion> <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup> </PropertyGroup>
@ -53,9 +53,8 @@
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="CookComputing.XmlRpcV2, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="CookComputing.XmlRpcV2">
<SpecificVersion>False</SpecificVersion> <HintPath>..\CookComputing.XmlRpcV2.dll</HintPath>
<HintPath>..\OpenERPOutlookPlugin\bin\Release\CookComputing.XmlRpcV2.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core"> <Reference Include="System.Core">
@ -81,7 +80,7 @@
<ItemGroup> <ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5"> <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible> <Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName> <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install> <Install>false</Install>
</BootstrapperPackage> </BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
@ -91,7 +90,7 @@
</BootstrapperPackage> </BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1"> <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible> <Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName> <ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install> <Install>true</Install>
</BootstrapperPackage> </BootstrapperPackage>
</ItemGroup> </ItemGroup>

View File

@ -1,6 +1,6 @@
 
Microsoft Visual Studio Solution File, Format Version 10.00 Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2008 # Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenERPOutlookPlugin", "OpenERPOutlookPlugin\OpenERPOutlookPlugin.csproj", "{F4B2219B-F235-400F-81B4-92F15250BBA4}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenERPOutlookPlugin", "OpenERPOutlookPlugin\OpenERPOutlookPlugin.csproj", "{F4B2219B-F235-400F-81B4-92F15250BBA4}"
EndProject EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "OpenERPOutlookPluginSetup", "OpenERPOutlookPluginSetup\OpenERPOutlookPluginSetup.vdproj", "{96333293-0156-4998-9065-42721CEB0368}" Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "OpenERPOutlookPluginSetup", "OpenERPOutlookPluginSetup\OpenERPOutlookPluginSetup.vdproj", "{96333293-0156-4998-9065-42721CEB0368}"

View File

@ -303,6 +303,7 @@ namespace OpenERPOutlookPlugin
foreach (outlook.MailItem mailitem in Tools.MailItems()) foreach (outlook.MailItem mailitem in Tools.MailItems())
{ {
Object[] contact = Cache.OpenERPOutlookPlugin.RedirectPartnerPage(mailitem); Object[] contact = Cache.OpenERPOutlookPlugin.RedirectPartnerPage(mailitem);
if ((int)contact[1] > 0) if ((int)contact[1] > 0)

View File

@ -95,7 +95,6 @@ namespace OpenERPOutlookPlugin
/* /*
* Will open the url into the web browser. * Will open the url into the web browser.
*/ */
System.Diagnostics.Process.Start(web_url.ToString()); System.Diagnostics.Process.Start(web_url.ToString());
} }
@ -163,9 +162,16 @@ namespace OpenERPOutlookPlugin
args.Add(attachments); args.Add(attachments);
object push_mail = this.Connection.Execute("plugin.handler", "push_message_outlook", args.ToArray()); object push_mail = this.Connection.Execute("plugin.handler", "push_message_outlook", args.ToArray());
object[] push = (object[])push_mail; object[] push = (object[])push_mail;
this.RedirectWeb(push[2].ToString()); if (Convert.ToInt32(push[1]) == 0)
return true; {
MessageBox.Show(push[3].ToString());
}
else
{
this.RedirectWeb(push[2].ToString());
}
return true;
} }
public long CreatePartnerRecord(string name) public long CreatePartnerRecord(string name)
{ {