[IMP] Improvement in thunderbird

bzr revid: ksa@tinyerp.co.in-20100804090515-120elt0h4pxgcd3v
This commit is contained in:
ksa (Open ERP) 2010-08-04 14:35:15 +05:30
parent ee6ccde777
commit 8f859de191
11 changed files with 112 additions and 46 deletions

View File

@ -2,7 +2,7 @@
############################################################################## ##############################################################################
# #
# OpenERP, Open Source Management Solution # OpenERP, Open Source Management Solution
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# Copyright (c) 2004 Axelor SPRL. (http://www.axelor.com) 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 # This program is free software: you can redistribute it and/or modify

View File

@ -32,7 +32,6 @@ class thunderbird_partner(osv.osv_memory):
_rec_name="sender" _rec_name="sender"
def mailcreate(self,cr,user,vals): def mailcreate(self,cr,user,vals):
print "vvvvvvvvvvv",vals
dictcreate = dict(vals) dictcreate = dict(vals)
import email import email
header_name = email.Header.decode_header(dictcreate['name']) 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): def update_contact(self,cr,user,vals):
dictcreate = dict(vals) dictcreate = dict(vals)
res_id = dictcreate.get('res_id',False) res_id = dictcreate.get('res_id',False)
result={}
if res_id: if res_id:
address_obj = self.pool.get('res.partner.address') address_obj = self.pool.get('res.partner.address')
address_data = address_obj.read(cr, user, int(res_id), [])
result={ result={
'partner_id': dictcreate.get('partner_id',False), 'partner_id': address_data['partner_id'] and address_data['partner_id'][0] or False,
'country_id': dictcreate.get('country_id', False), 'country_id': dictcreate['country_id'] and int(dictcreate['country_id'][0]) or False,
'state_id': dictcreate('state_id', False), 'state_id': dictcreate['state_id'] and int(dictcreate['state_id'][0]) or False,
'name': dictcreate.get('name', False), 'name': dictcreate['name'],
'street': dictcreate.get('street', False), 'street': dictcreate['street'],
'street2': dictcreate.get('street2', False), 'street2': dictcreate['street2'],
'zip': dictcreate.get('zip', False), 'zip': dictcreate['zip'],
'city': dictcreate.get('city', False), 'city': dictcreate['city'],
'phone': dictcreate.get('phone', False), 'phone': dictcreate['phone'],
'fax': dictcreate.get('fax', False), 'fax': dictcreate['fax'],
'mobile': dictcreate.get('mobile', False), 'mobile': dictcreate['mobile'],
'email': dictcreate.get('email', False), 'email': dictcreate['email'],
} }
address_obj.write(cr, user,res_id,result ) address_obj.write(cr, user,res_id,result )
return True return True
def create_partner(self,cr,user,vals): def create_partner(self,cr,user,vals):

View File

@ -3,7 +3,7 @@
<!DOCTYPE window SYSTEM "chrome://openerp_plugin/locale/config_change.dtd"> <!DOCTYPE window SYSTEM "chrome://openerp_plugin/locale/config_change.dtd">
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml" onload="config_change_load()" xmlns:html="http://www.w3.org/1999/xhtml" onload="config_change_load()"
title="Server" height="160" width="320"> title="Server" height="140" width="240">
<script type="text/javascript" src="chrome://openerp_plugin/content/tiny_xmlrpc.js"></script> <script type="text/javascript" src="chrome://openerp_plugin/content/tiny_xmlrpc.js"></script>
<script type="text/javascript" src="chrome://openerp_plugin/content/config.js"></script> <script type="text/javascript" src="chrome://openerp_plugin/content/config.js"></script>
<script type="text/javascript" src="chrome://openerp_plugin/content/loaddata.js"></script> <script type="text/javascript" src="chrome://openerp_plugin/content/loaddata.js"></script>
@ -18,7 +18,8 @@
<hbox> <hbox>
<label id="lblport" control="txtcport" value="&lblport.label;" width="80"/> <label id="lblport" control="txtcport" value="&lblport.label;" width="80"/>
<textbox id="txtcport" width="100" /> <textbox id="txtcport" width="100" />
</hbox> </hbox>
</groupbox> </groupbox>
<hbox align="rightr"> <hbox align="rightr">
<spacer width="50"/> <spacer width="50"/>

View File

@ -45,11 +45,12 @@ var myPrefObserver =
//set the initial value of name and email field of create contact window //set the initial value of name and email field of create contact window
createContact: function() createContact: function()
{ {
//document.getElementById("txtselectpartner").value= getPartnerName(); //document.getElementById("txtselectpartner").value= getPartnerID();
document.getElementById("txtname").value= getSenderName(); document.getElementById("txtname").value= getSenderName();
document.getElementById("txtemail").value= getSenderEmail(); document.getElementById("txtemail").value= getSenderEmail();
document.getElementById("country").value=getAllCountry(); document.getElementById("country").value=getAllCountry();
document.getElementById("state").value=getAllState(); document.getElementById("state").value=getAllState();
setPartnerId(0);
}, },
//sets the value of email information in preferences and adds observer for the window //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("txtstreet2").value= getStreet2();
document.getElementById("txtzip").value= getZipCode(); document.getElementById("txtzip").value= getZipCode();
document.getElementById("txtcity").value= getCity(); document.getElementById("txtcity").value= getCity();
// document.getElementById("txtcountry").value= getCountry();
// document.getElementById("txtstate").value= getState();
document.getElementById("txtoffice").value= getOfficenumber(); document.getElementById("txtoffice").value= getOfficenumber();
document.getElementById("txtfax").value= getFax(); document.getElementById("txtfax").value= getFax();
document.getElementById("txtmobile").value= getMobilenumber(); document.getElementById("txtmobile").value= getMobilenumber();
document.getElementById("txtemail").value= getSenderEmail(); document.getElementById("txtemail").value= getSenderEmail();
document.getElementById("country").value=getAllCountry(); document.getElementById("country").value=getAllCountry();
document.getElementById("state").value=getAllState(); document.getElementById("state").value=getAllState();
}, },
//unregistering the window observer //unregistering the window observer

View File

@ -176,7 +176,73 @@ function searchmail()
window.open("chrome://openerp_plugin/content/plugin.xul", "", "chrome, resizable=yes"); 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 //function to open the configuration window
var Config = { var Config = {
onLoad: function() { onLoad: function() {
@ -219,13 +285,9 @@ var Address = {
this.initialized=true; this.initialized=true;
}, },
onMenuItemCommand: function(){ onMenuItemCommand: function(){
// if(GetNumSelectedMessages() < 1 || GetNumSelectedMessages() > 1){ open_contact();
// alert("You must select only one mail to archive");
//return false
//}
searchContact(); searchContact();
window.open("chrome://openerp_plugin/content/address.xul", "", "chrome");
} }
}; };

View File

@ -16,7 +16,7 @@
<hbox id="root"> <hbox id="root">
<vbox width="400"> <vbox width="400">
<groupbox height="30" id="existsobjectgroup" width="400"> <groupbox height="30" id="existsobjectgroup" width="400">
<caption label="&gptinydoc.label;" /> <caption label="&gptinyobj.label;" />
<hbox> <hbox>
<label id="lblsearch" control="txtvalueobj" value="&search.label;"/> <label id="lblsearch" control="txtvalueobj" value="&search.label;"/>
<textbox id="txtvalueobj" size="30"/> <textbox id="txtvalueobj" size="30"/>
@ -25,7 +25,7 @@
<vbox align="left" id="checkbox-dynamic"> <vbox align="left" id="checkbox-dynamic">
</vbox> </vbox>
<hbox align="center"> <hbox align="center">
<image src='chrome://openerp_plugin/skin/perform.gif'/> <image src='chrome://tiny_plugin/skin/perform.gif'/>
<checkbox id="cbxselectall" oncommand="selectAllCheckbox();" label="&cbxselectall.label;" checked="false"/> <checkbox id="cbxselectall" oncommand="selectAllCheckbox();" label="&cbxselectall.label;" checked="false"/>
<spacer width="10"/> <spacer width="10"/>
<button label="&bsearch.label;" oncommand="searchCheckbox()" image="&imagesearch.value;" accesskey="s"/> <button label="&bsearch.label;" oncommand="searchCheckbox()" image="&imagesearch.value;" accesskey="s"/>
@ -48,10 +48,10 @@
</vbox> </vbox>
<vbox> <vbox>
<groupbox id="newobjectgroup" align="center" width="170" height="375"> <groupbox id="newobjectgroup" align="center" width="170" height="375">
<caption label="&newdocument.label;" /> <caption label="&newobject.label;" />
<hbox> <hbox>
<label id="lblex" value=" "/> <label id="lblex" value=" "/>
<label id="lblex3" control="section" value="&document.label;"/> <label id="lblex3" control="section" value="&object.label;"/>
<menulist id="section" width="150"> <menulist id="section" width="150">
<menupopup> <menupopup>
<menuitem label="" value=""/> <menuitem label="" value=""/>
@ -65,7 +65,7 @@
<label id="lblsection" value=" "/> <label id="lblsection" value=" "/>
<separator class="groove-thin" orient="horizontal" width="180"/> <separator class="groove-thin" orient="horizontal" width="180"/>
<tabpanels> <tabpanels>
<tabpanel id="contact"> <tabpanel id="contact">
<hbox> <hbox>
<label id="lblsection" control="section" value="&partner.label;"/> <label id="lblsection" control="section" value="&partner.label;"/>

View File

@ -303,7 +303,7 @@ function setCity(argCity){
//set preference value for country //set preference value for country
function setCountry(argCountry){ function setCountry(argCountry){
getPref().setCharPref('country',argCountry) getPref().setCharPref('country',argCountry)
} }
//set preference value for state //set preference value for state
@ -940,6 +940,7 @@ var listSearchContactHandler = {
var strlResult = arrIdList.QueryElementAt(i, Components.interfaces.nsISupportsArray); var strlResult = arrIdList.QueryElementAt(i, Components.interfaces.nsISupportsArray);
var strlSearchResult = strlResult.QueryElementAt(0, Components.interfaces.nsISupportsCString); var strlSearchResult = strlResult.QueryElementAt(0, Components.interfaces.nsISupportsCString);
var strlSearchResultValue = strlResult.QueryElementAt(1, Components.interfaces.nsISupportsCString); var strlSearchResultValue = strlResult.QueryElementAt(1, Components.interfaces.nsISupportsCString);
if(strlSearchResult=="partner_name"){ if(strlSearchResult=="partner_name"){
setPartnerName(strlSearchResultValue); setPartnerName(strlSearchResultValue);
var t = getPartnerName();} var t = getPartnerName();}
@ -1326,8 +1327,8 @@ function archivemail(){
strmethod.data = 'mailcreate'; strmethod.data = 'mailcreate';
var strobj = xmlRpcClient.createType(xmlRpcClient.STRING,{}); var strobj = xmlRpcClient.createType(xmlRpcClient.STRING,{});
strobj.data = 'thunderbird.partner'; strobj.data = 'thunderbird.partner';
var a = ['sender','receiver','date','title','description']; var a = ['name','object','date','email_from','email_cc','description','user_id'];
var b = [getSenderEmail(),getReceiverEmail(),getReceivedDate(),getSubject(),getMessageBody()]; var b = [getSubject(),object,getReceivedDate(),getSenderEmail(),getCCList(),getMessageBody(),branchobj.getIntPref('userid')];
var arrofarr = dictcontact(a,b); var arrofarr = dictcontact(a,b);
xmlRpcClient.asyncCall(listArchiveHandler,null,'execute',[strDbName,struids,strpass,strobj,strmethod,arrofarr],6); xmlRpcClient.asyncCall(listArchiveHandler,null,'execute',[strDbName,struids,strpass,strobj,strmethod,arrofarr],6);
} }
@ -1367,23 +1368,23 @@ var listCreateContactHandler = {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserAccess'); netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserAccess');
var createId = result.QueryInterface(Components.interfaces.nsISupportsPRInt32); var createId = result.QueryInterface(Components.interfaces.nsISupportsPRInt32);
setContactId(createId); setContactId(createId);
//alert("Contact Created Successfully."); alert("Contact Created Successfully.");
window.close(); window.close();
}, },
onFault: function (client, ctxt, fault) { onFault: function (client, ctxt, fault) {
//alert('XML-RPC Fault: '+fault); alert('XML-RPC Fault: '+fault);
}, },
onError: function (client, ctxt, status, errorMsg) { onError: function (client, ctxt, status, errorMsg) {
//alert('Error: '+errorMsg); alert('Error: '+errorMsg);
} }
} }
var listUpdateContactHandler = { var listUpdateContactHandler = {
onResult: function(client, context, result) { onResult: function(client, context, result) {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserAccess'); netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserAccess');
var partnerId = result.QueryInterface(Components.interfaces.nsISupportsPRInt32); var ResourceId = result.QueryInterface(Components.interfaces.nsISupportsPRInt32);
setResourceId(partnerId); setResourceId(ResourceId);
//alert("Contact Created Successfully."); //alert("Contact Created Successfully.");
window.close(); window.close();
}, },
@ -1417,7 +1418,7 @@ function createContact(){
var arrofarr = dictcontact(a,b); var arrofarr = dictcontact(a,b);
xmlRpcClient.asyncCall(listCreateContactHandler,null,'execute',[strDbName,struids,strpass,strobj,strmethod,arrofarr],6); xmlRpcClient.asyncCall(listCreateContactHandler,null,'execute',[strDbName,struids,strpass,strobj,strmethod,arrofarr],6);
} }
//ksa
function UpdateContact(){ function UpdateContact(){
var branchobj = getPref(); var branchobj = getPref();
setServerService('xmlrpc/object'); setServerService('xmlrpc/object');
@ -1433,6 +1434,7 @@ function UpdateContact(){
strmethod.data = 'update_contact'; strmethod.data = 'update_contact';
var strobj = xmlRpcClient.createType(xmlRpcClient.STRING,{}); var strobj = xmlRpcClient.createType(xmlRpcClient.STRING,{});
strobj.data = 'thunderbird.partner'; strobj.data = 'thunderbird.partner';
alert(getResourceId());
var a = ['res_id','partner_id','name','street','street2','zip','city','country_id','state_id','phone','fax','mobile','email']; var a = ['res_id','partner_id','name','street','street2','zip','city','country_id','state_id','phone','fax','mobile','email'];
var b = [getResourceId(),getPartnerName(),getSenderName(),document.getElementById("txtstreet").value,document.getElementById("txtstreet2").value,document.getElementById("txtzip").value, document.getElementById("txtcity").value,document.getElementById("country").value,document.getElementById("state").value,document.getElementById("txtoffice").value,document.getElementById("txtfax").value,document.getElementById("txtmobile").value,getSenderEmail()]; var b = [getResourceId(),getPartnerName(),getSenderName(),document.getElementById("txtstreet").value,document.getElementById("txtstreet2").value,document.getElementById("txtzip").value, document.getElementById("txtcity").value,document.getElementById("country").value,document.getElementById("state").value,document.getElementById("txtoffice").value,document.getElementById("txtfax").value,document.getElementById("txtmobile").value,getSenderEmail()];
var arrofarr = dictcontact(a,b); var arrofarr = dictcontact(a,b);

View File

@ -35,8 +35,8 @@ Licenced under the terms of OpenERP Public License (OEPL) v1.1 ">
<!ENTITY tinyerp_s.value "The Tiny Company"> <!ENTITY tinyerp_s.value "The Tiny Company">
<!ENTITY imageicon.value "chrome://openerp_plugin/skin/NEWT1.png"> <!ENTITY imageicon.value "chrome://openerp_plugin/skin/NEWT1.png">
<!ENTITY gpAbout.label "About Plugin"> <!ENTITY gpAbout.label "About OpenERP Thunderbird Plugin">
<!ENTITY develop.value "This Thunderbird Plug-in for OpenERP has been developed by OpenERP SA &amp; Axelor"> <!ENTITY develop.value "This Thunderbird Plugin for OpenERP has been developed by OpenERP SA &amp; Axelor">
<!ENTITY information.value "For more information, please visit our website"> <!ENTITY information.value "For more information, please visit our website">
<!ENTITY contact.label "Contact Us"> <!ENTITY contact.label "Contact Us">
<!ENTITY contact.value "info@axelor.com"> <!ENTITY contact.value "info@axelor.com">

View File

@ -1,6 +1,6 @@
<!ENTITY title.label "Archieve To OpenERP"> <!ENTITY title.label "Archieve To OpenERP">
<!ENTITY gptinydoc.label "Link to an Existing Document"> <!ENTITY gptinyobj.label "Link to an Existing Document">
<!ENTITY newdocument.label "New Documents"> <!ENTITY newobject.label "New Documents">
<!ENTITY bsearch.label "Search"> <!ENTITY bsearch.label "Search">
<!ENTITY close.label "Close"> <!ENTITY close.label "Close">
<!ENTITY attach.label "Upload to OpenERP"> <!ENTITY attach.label "Upload to OpenERP">
@ -17,7 +17,7 @@
<!ENTITY cbxcase.label "Case"> <!ENTITY cbxcase.label "Case">
<!ENTITY cbxtask.label "Task"> <!ENTITY cbxtask.label "Task">
<!ENTITY cbxselectall.label "Select All"> <!ENTITY cbxselectall.label "Select All">
<!ENTITY document.label "Type of Document :"> <!ENTITY object.label "Type of Document :">
<!ENTITY partner.label "Create New Contact :"> <!ENTITY partner.label "Create New Contact :">
<!ENTITY search.label "Search :"> <!ENTITY search.label "Search :">
<!ENTITY listSearchBox.header "Name"> <!ENTITY listSearchBox.header "Name">