diff --git a/addons/thunderbird/__openerp__.py b/addons/thunderbird/__openerp__.py index 4c2820c78e2..703aec6ad67 100644 --- a/addons/thunderbird/__openerp__.py +++ b/addons/thunderbird/__openerp__.py @@ -2,7 +2,7 @@ ############################################################################## # # OpenERP, Open Source Management Solution -# Copyright (C) 2004-2008 Tiny SPRL (). All Rights Reserved +# Copyright (C) 2004-2010 Tiny SPRL (). All Rights Reserved # Copyright (c) 2004 Axelor SPRL. (http://www.axelor.com) All Rights Reserved. # # This program is free software: you can redistribute it and/or modify diff --git a/addons/thunderbird/partner/partner.py b/addons/thunderbird/partner/partner.py index 54b1ad8dbaa..53050ec55a1 100644 --- a/addons/thunderbird/partner/partner.py +++ b/addons/thunderbird/partner/partner.py @@ -32,7 +32,6 @@ class thunderbird_partner(osv.osv_memory): _rec_name="sender" def mailcreate(self,cr,user,vals): - print "vvvvvvvvvvv",vals dictcreate = dict(vals) import email header_name = email.Header.decode_header(dictcreate['name']) @@ -82,23 +81,25 @@ class thunderbird_partner(osv.osv_memory): def update_contact(self,cr,user,vals): dictcreate = dict(vals) res_id = dictcreate.get('res_id',False) + result={} if res_id: address_obj = self.pool.get('res.partner.address') + address_data = address_obj.read(cr, user, int(res_id), []) result={ - 'partner_id': dictcreate.get('partner_id',False), - 'country_id': dictcreate.get('country_id', False), - 'state_id': dictcreate('state_id', False), - 'name': dictcreate.get('name', False), - 'street': dictcreate.get('street', False), - 'street2': dictcreate.get('street2', False), - 'zip': dictcreate.get('zip', False), - 'city': dictcreate.get('city', False), - 'phone': dictcreate.get('phone', False), - 'fax': dictcreate.get('fax', False), - 'mobile': dictcreate.get('mobile', False), - 'email': dictcreate.get('email', False), - } - address_obj.write(cr, user,res_id,result ) + 'partner_id': address_data['partner_id'] and address_data['partner_id'][0] or False, + 'country_id': dictcreate['country_id'] and int(dictcreate['country_id'][0]) or False, + 'state_id': dictcreate['state_id'] and int(dictcreate['state_id'][0]) or False, + 'name': dictcreate['name'], + 'street': dictcreate['street'], + 'street2': dictcreate['street2'], + 'zip': dictcreate['zip'], + 'city': dictcreate['city'], + 'phone': dictcreate['phone'], + 'fax': dictcreate['fax'], + 'mobile': dictcreate['mobile'], + 'email': dictcreate['email'], + } + address_obj.write(cr, user,res_id,result ) return True def create_partner(self,cr,user,vals): diff --git a/addons/thunderbird/plugin/openerp_plugin.xpi b/addons/thunderbird/plugin/openerp_plugin.xpi index 300d88731f8..4e0973e58e4 100644 Binary files a/addons/thunderbird/plugin/openerp_plugin.xpi and b/addons/thunderbird/plugin/openerp_plugin.xpi differ diff --git a/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin.jar b/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin.jar index 7c187a94a59..8a64c9646f9 100644 Binary files a/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin.jar and b/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin.jar differ diff --git a/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/config_change.xul b/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/config_change.xul index 491a7cdae60..79af8564da5 100644 --- a/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/config_change.xul +++ b/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/config_change.xul @@ -3,7 +3,7 @@ + title="Server" height="140" width="240"> @@ -18,7 +18,8 @@ + + diff --git a/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/loaddata.js b/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/loaddata.js index 196eb369b22..4bc4193fb70 100755 --- a/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/loaddata.js +++ b/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/loaddata.js @@ -45,11 +45,12 @@ var myPrefObserver = //set the initial value of name and email field of create contact window createContact: function() { - //document.getElementById("txtselectpartner").value= getPartnerName(); + //document.getElementById("txtselectpartner").value= getPartnerID(); document.getElementById("txtname").value= getSenderName(); document.getElementById("txtemail").value= getSenderEmail(); document.getElementById("country").value=getAllCountry(); document.getElementById("state").value=getAllState(); + setPartnerId(0); }, //sets the value of email information in preferences and adds observer for the window @@ -98,14 +99,13 @@ var myPrefObserver = document.getElementById("txtstreet2").value= getStreet2(); document.getElementById("txtzip").value= getZipCode(); document.getElementById("txtcity").value= getCity(); - // document.getElementById("txtcountry").value= getCountry(); - // document.getElementById("txtstate").value= getState(); document.getElementById("txtoffice").value= getOfficenumber(); document.getElementById("txtfax").value= getFax(); document.getElementById("txtmobile").value= getMobilenumber(); document.getElementById("txtemail").value= getSenderEmail(); document.getElementById("country").value=getAllCountry(); document.getElementById("state").value=getAllState(); + }, //unregistering the window observer diff --git a/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/overlay.js b/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/overlay.js index 19f7344686d..9be5ff74f7b 100755 --- a/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/overlay.js +++ b/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/overlay.js @@ -176,7 +176,73 @@ function searchmail() window.open("chrome://openerp_plugin/content/plugin.xul", "", "chrome, resizable=yes"); } } + +function open_contact() +{ + setTimeout("createConnection()",5000) + if (getconnect_server() == "false") + { + alert("Please Login To The Database First !") + return false; + } + setTimeout("module_install()", 10000) + if (getmodule_install() == "no") + { + alert("Please install the thunderbird module on your '" + getDbName() +"' database Or try again !"); + return false + } + if(GetNumSelectedMessages() < 1 || GetNumSelectedMessages() > 1){ + alert("You must select only one mail For Open Contact Detail"); + return false + } + //gives the selected email uri + var messageUri= gDBView.URIForFirstSelectedMessage; + + var messenger = Components.classes['@mozilla.org/messenger;1'].createInstance(Components.interfaces.nsIMessenger); + + //gives the selected email object + var message = messenger.messageServiceFromURI(messageUri).messageURIToMsgHdr(messageUri); + + //functionality to split the author name and email + if(message.author.charAt(0) == '"'){ + sendername = message.author.split('"')[1].split('"')[0]; + } + else if(message.author.indexOf('<')!=-1){ + sendername = message.author.split('<')[0]; + } + else{ + sendername = message.author; + } + if(message.author.indexOf('<')!=-1){ + senderemail = message.author.split('<')[1].split('>')[0]; + } + else{ + senderemail = message.author + } + + //set the initial information for the selected email + setSenderEmail(senderemail); + setSenderName(sendername); + setPartnerName(""); + setStreet(""); + setStreet2(""); + setZipCode(""); + setCity(""); + setOfficenumber(""); + setFax(""); + setMobilenumber(""); + + if (getmodule_install() == "no") + { + alert("Please install the thunderbird module on your '" + getDbName() +"' database Or try again !"); + return false + } + window.open("chrome://openerp_plugin/content/address.xul", "", "chrome, resizable=yes"); + +} + + //function to open the configuration window var Config = { onLoad: function() { @@ -219,13 +285,9 @@ var Address = { this.initialized=true; }, - onMenuItemCommand: function(){ - // if(GetNumSelectedMessages() < 1 || GetNumSelectedMessages() > 1){ - // alert("You must select only one mail to archive"); - //return false - //} + onMenuItemCommand: function(){ + open_contact(); searchContact(); - window.open("chrome://openerp_plugin/content/address.xul", "", "chrome"); } }; diff --git a/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/plugin.xul b/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/plugin.xul index f151408b7de..2847638f756 100644 --- a/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/plugin.xul +++ b/addons/thunderbird/plugin/openerp_plugin/chrome/openerp_plugin/content/plugin.xul @@ -16,7 +16,7 @@ - +