[Fix] base_report_designer: Correct usability issue in open office designer
bzr revid: sbh@tinyerp.com-20110516105930-iu14exa2hqwmc2tz
This commit is contained in:
Binary file not shown.
@@ -19,7 +19,7 @@
|
||||
<node oor:name="Submenu">
|
||||
<node oor:name="m11" oor:op="replace">
|
||||
<prop oor:name="URL" oor:type="xs:string">
|
||||
<value>service:org.openoffice.openerp.report.serverparam?execute</value>
|
||||
<value>service:org.openoffice.openerp.report.change?execute</value>
|
||||
</prop>
|
||||
<prop oor:name="Title" oor:type="xs:string">
|
||||
<value/>
|
||||
@@ -283,7 +283,7 @@
|
||||
<node oor:name="org.openoffice.openerp.report" oor:op="replace">
|
||||
<node oor:name="m11" oor:op="replace">
|
||||
<prop oor:name="URL" oor:type="xs:string">
|
||||
<value>service:org.openoffice.openerp.report.serverparam?execute</value>
|
||||
<value>service:org.openoffice.openerp.report.change?execute</value>
|
||||
</prop>
|
||||
<prop oor:name="ImageIdentifier" oor:type="xs:string">
|
||||
<value/>
|
||||
@@ -593,7 +593,7 @@
|
||||
</node>
|
||||
<node oor:name="org.openoffice.openerp.report.image8" oor:op="replace">
|
||||
<prop oor:name="URL">
|
||||
<value>service:org.openoffice.openerp.report.serverparam?execute</value>
|
||||
<value>service:org.openoffice.openerp.report.change?execute</value>
|
||||
</prop>
|
||||
<node oor:name="UserDefinedImages">
|
||||
<prop oor:name="ImageSmallURL" oor:type="xs:string">
|
||||
|
||||
@@ -44,36 +44,49 @@
|
||||
#
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import uno
|
||||
import string
|
||||
import unohelper
|
||||
import xmlrpclib
|
||||
from com.sun.star.task import XJobExecutor
|
||||
if __name__<>"package":
|
||||
from lib.gui import *
|
||||
from lib.error import ErrorDialog
|
||||
from lib.functions import *
|
||||
from lib.logreport import *
|
||||
from lib.rpc import *
|
||||
from ServerParameter import *
|
||||
database="test"
|
||||
|
||||
class Change:
|
||||
def __init__(self, aVal= None, sURL=""):
|
||||
class Change( unohelper.Base, XJobExecutor ):
|
||||
def __init__(self,ctx):
|
||||
self.ctx = ctx
|
||||
self.module = "openerp_report"
|
||||
self.version = "0.1"
|
||||
desktop=getDesktop()
|
||||
log_detail(self)
|
||||
self.logobj=Logger()
|
||||
doc = desktop.getCurrentComponent()
|
||||
docinfo=doc.getDocumentInfo()
|
||||
self.win=DBModalDialog(60, 50, 120, 90, "Connect to Open ERP Server")
|
||||
|
||||
self.win.addFixedText("lblVariable", 38, 12, 25, 15, "Server ")
|
||||
|
||||
self.win.addEdit("txtHost",-2,9,60,15,sURL[sURL.find("/")+2:sURL.rfind(":")])
|
||||
self.win.addEdit("txtHost",-2,9,60,15,'localhost')
|
||||
|
||||
self.win.addFixedText("lblReportName",45 , 31, 15, 15, "Port ")
|
||||
self.win.addEdit("txtPort",-2,28,60,15,sURL[sURL.rfind(":")+1:])
|
||||
self.win.addEdit("txtPort",-2,28,60,15,"8069")
|
||||
|
||||
self.win.addFixedText("lblLoginName", 2, 51, 60, 15, "Protocol Connection")
|
||||
|
||||
self.win.addComboListBox("lstProtocol", -2, 48, 60, 15, True)
|
||||
self.lstProtocol = self.win.getControl( "lstProtocol" )
|
||||
|
||||
# self.lstProtocol.addItem( "XML-RPC", 0)
|
||||
#self.lstProtocol.addItem( "XML-RPC secure", 1)
|
||||
#self.lstProtocol.addItem( "NET-RPC (faster)", 2)
|
||||
|
||||
self.win.addButton( 'btnOK', -2, -5, 30, 15, 'Ok', actionListenerProc = self.btnOk_clicked )
|
||||
self.win.addButton( 'btnNext', -2, -5, 30, 15, 'Next', actionListenerProc = self.btnNext_clicked )
|
||||
|
||||
self.win.addButton( 'btnCancel', -2 - 30 - 5 ,-5, 30, 15, 'Cancel', actionListenerProc = self.btnCancel_clicked )
|
||||
aVal=''
|
||||
self.aVal=aVal
|
||||
sValue=''
|
||||
self.protocol = {
|
||||
'XML-RPC': 'http://',
|
||||
'XML-RPC secure': 'https://',
|
||||
@@ -81,31 +94,32 @@ class Change:
|
||||
}
|
||||
for i in self.protocol.keys():
|
||||
self.lstProtocol.addItem(i,self.lstProtocol.getItemCount() )
|
||||
|
||||
sValue=self.protocol.keys()[0]
|
||||
if sURL<>"":
|
||||
sValue=self.protocol.keys()[self.protocol.values().index(sURL[:sURL.find("/")+2])]
|
||||
|
||||
self.win.doModalDialog( "lstProtocol", sValue)
|
||||
|
||||
def btnOk_clicked(self,oActionEvent):
|
||||
def btnNext_clicked(self,oActionEvent):
|
||||
global url
|
||||
url = self.protocol[self.win.getListBoxSelectedItem("lstProtocol")]+self.win.getEditText("txtHost")+":"+self.win.getEditText("txtPort")
|
||||
self.sock=RPCSession(url)
|
||||
desktop=getDesktop()
|
||||
doc = desktop.getCurrentComponent()
|
||||
docinfo=doc.getDocumentInfo()
|
||||
docinfo.setUserFieldValue(0,url)
|
||||
res=self.sock.listdb()
|
||||
if res == -1:
|
||||
self.aVal.append(url)
|
||||
elif res == 0:
|
||||
self.aVal.append("No Database found !!!")
|
||||
else:
|
||||
self.aVal.append(url)
|
||||
self.aVal.append(res)
|
||||
aVal=''
|
||||
#aVal= Fetature used
|
||||
try:
|
||||
url = self.protocol[self.win.getListBoxSelectedItem("lstProtocol")]+self.win.getEditText("txtHost")+":"+self.win.getEditText("txtPort")
|
||||
self.sock=RPCSession(url)
|
||||
desktop=getDesktop()
|
||||
doc = desktop.getCurrentComponent()
|
||||
docinfo=doc.getDocumentInfo()
|
||||
docinfo.setUserFieldValue(0,url)
|
||||
res=self.sock.listdb()
|
||||
self.win.endExecute()
|
||||
ServerParameter(aVal,url)
|
||||
except :
|
||||
import traceback,sys
|
||||
info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
|
||||
self.logobj.log_write('ServerParameter', LOG_ERROR, info)
|
||||
def btnCancel_clicked(self,oActionEvent):
|
||||
self.win.endExecute()
|
||||
|
||||
|
||||
def btnCancel_clicked( self, oActionEvent ):
|
||||
self.win.endExecute()
|
||||
if __name__<>"package" and __name__=="__main__":
|
||||
Change(None)
|
||||
elif __name__=="package":
|
||||
g_ImplementationHelper.addImplementation( Change, "org.openoffice.openerp.report.change", ("com.sun.star.task.Job",),)
|
||||
|
||||
|
||||
@@ -51,5 +51,5 @@ if __name__<>"package":
|
||||
class LoginTest:
|
||||
def __init__(self):
|
||||
if not loginstatus:
|
||||
ServerParameter(None)
|
||||
Change(None)
|
||||
|
||||
|
||||
+40
-61
@@ -59,8 +59,7 @@ if __name__<>"package":
|
||||
database="test"
|
||||
|
||||
class ServerParameter( unohelper.Base, XJobExecutor ):
|
||||
def __init__(self,ctx):
|
||||
self.ctx = ctx
|
||||
def __init__(self, aVal= None, sURL=""):
|
||||
self.module = "openerp_report"
|
||||
self.version = "0.1"
|
||||
desktop=getDesktop()
|
||||
@@ -69,19 +68,12 @@ class ServerParameter( unohelper.Base, XJobExecutor ):
|
||||
doc = desktop.getCurrentComponent()
|
||||
docinfo=doc.getDocumentInfo()
|
||||
self.win=DBModalDialog(60, 50, 160, 108, "Server Connection Parameter")
|
||||
|
||||
self.win.addFixedText("lblVariable", 2, 12, 35, 15, "Server URL")
|
||||
if docinfo.getUserFieldValue(0)=="":
|
||||
docinfo.setUserFieldValue(0,"http://localhost:8069")
|
||||
self.win.addEdit("txtHost",-34,9,91,15,docinfo.getUserFieldValue(0))
|
||||
self.win.addButton('btnChange',-2 ,9,30,15,'Change', actionListenerProc = self.btnChange_clicked )
|
||||
|
||||
docinfo.setUserFieldValue(0,"http://localhost:8069")
|
||||
self.win.addEdit("txtHost",-20,9,105,15,sURL)
|
||||
self.win.addFixedText("lblDatabaseName", 6, 31, 31, 15, "Database")
|
||||
#self.win.addFixedText("lblMsg", -2,28,123,15)
|
||||
# self.win.addComboListBox("lstDatabase", -2,28,123,15, True)
|
||||
# self.lstDatabase = self.win.getControl( "lstDatabase" )
|
||||
#self.win.selectListBoxItem( "lstDatabase", docinfo.getUserFieldValue(2), True )
|
||||
#self.win.setEnabled("lblMsg",False)
|
||||
|
||||
|
||||
self.win.addFixedText("lblLoginName", 17, 51, 20, 15, "Login")
|
||||
self.win.addEdit("txtLoginName",-2,48,123,15,docinfo.getUserFieldValue(1))
|
||||
@@ -92,8 +84,9 @@ class ServerParameter( unohelper.Base, XJobExecutor ):
|
||||
|
||||
|
||||
self.win.addButton('btnOK',-2 ,-5, 60,15,'Connect' ,actionListenerProc = self.btnOk_clicked )
|
||||
|
||||
self.win.addButton('btnCancel',-2 - 60 - 5 ,-5, 35,15,'Cancel' ,actionListenerProc = self.btnCancel_clicked )
|
||||
self.win.addButton('btnPrevious',15 -80 ,-5,50,15,'Previous',actionListenerProc = self.btnPrevious_clicked)
|
||||
self.win.addButton('btnCancel',-2 - 110 - 5 ,-5, 35,15,'Cancel' ,actionListenerProc = self.btnCancel_clicked )
|
||||
|
||||
sValue=""
|
||||
if docinfo.getUserFieldValue(0)<>"":
|
||||
global url
|
||||
@@ -125,7 +118,6 @@ class ServerParameter( unohelper.Base, XJobExecutor ):
|
||||
|
||||
def btnOk_clicked(self,oActionEvent):
|
||||
|
||||
|
||||
sLogin=self.win.getEditText("txtLoginName")
|
||||
sPassword=self.win.getEditText("txtPassword")
|
||||
global url
|
||||
@@ -136,62 +128,49 @@ class ServerParameter( unohelper.Base, XJobExecutor ):
|
||||
sDatabase=self.win.getListBoxSelectedItem("lstDatabase")
|
||||
self.sock=RPCSession(url)
|
||||
UID = self.sock.login(sDatabase,sLogin,sPassword)
|
||||
if not UID :
|
||||
if not UID or UID==-1 :
|
||||
ErrorDialog("Connection Refuse...","Please enter valid Login/Password")
|
||||
self.win.endExecute()
|
||||
try:
|
||||
ids_module =self.sock.execute(sDatabase, UID, sPassword, 'ir.module.module', 'search', [('name','=','base_report_designer'),('state', '=', 'installed')])
|
||||
info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
|
||||
self.logobj.log_write('ServerParameter', LOG_ERROR, info)
|
||||
|
||||
if not len(ids_module):
|
||||
ErrorDialog("Please Install base_report_designer module", "", "Module Uninstalled Error")
|
||||
self.logobj.log_write('Module Not Found',LOG_WARNING, ':base_report_designer not install in database %s' % (sDatabase))
|
||||
self.win.endExecute()
|
||||
else:
|
||||
desktop=getDesktop()
|
||||
doc = desktop.getCurrentComponent()
|
||||
docinfo=doc.getDocumentInfo()
|
||||
docinfo.setUserFieldValue(0,self.win.getEditText("txtHost"))
|
||||
docinfo.setUserFieldValue(1,self.win.getEditText("txtLoginName"))
|
||||
global passwd
|
||||
passwd=self.win.getEditText("txtPassword")
|
||||
global loginstatus
|
||||
loginstatus=True
|
||||
global database
|
||||
database=sDatabase
|
||||
global uid
|
||||
uid=UID
|
||||
#docinfo.setUserFieldValue(2,self.win.getListBoxSelectedItem("lstDatabase"))
|
||||
#docinfo.setUserFieldValue(3,"")
|
||||
|
||||
ErrorDialog(" You can start creating your report in \n \t the current document.","After Creating sending to the server.","Message")
|
||||
self.logobj.log_write('successful login',LOG_INFO, ':successful login from %s using database %s' % (sLogin, sDatabase))
|
||||
self.win.endExecute()
|
||||
|
||||
except :
|
||||
import traceback,sys
|
||||
info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
|
||||
self.logobj.log_write('ServerParameter', LOG_ERROR, info)
|
||||
|
||||
if not len(ids_module):
|
||||
ErrorDialog("Please Install base_report_designer module", "", "Module Uninstalled Error")
|
||||
self.logobj.log_write('Module Not Found',LOG_WARNING, ':base_report_designer not install in database %s' % (sDatabase))
|
||||
self.win.endExecute()
|
||||
else:
|
||||
desktop=getDesktop()
|
||||
doc = desktop.getCurrentComponent()
|
||||
docinfo=doc.getDocumentInfo()
|
||||
docinfo.setUserFieldValue(0,self.win.getEditText("txtHost"))
|
||||
docinfo.setUserFieldValue(1,self.win.getEditText("txtLoginName"))
|
||||
global passwd
|
||||
passwd=self.win.getEditText("txtPassword")
|
||||
global loginstatus
|
||||
loginstatus=True
|
||||
global database
|
||||
database=sDatabase
|
||||
global uid
|
||||
uid=UID
|
||||
#docinfo.setUserFieldValue(2,self.win.getListBoxSelectedItem("lstDatabase"))
|
||||
#docinfo.setUserFieldValue(3,"")
|
||||
|
||||
ErrorDialog(" You can start creating your report in \n \t the current document.","After Creating sending to the server.","Message")
|
||||
self.logobj.log_write('successful login',LOG_INFO, ':successful login from %s using database %s' % (sLogin, sDatabase))
|
||||
self.win.endExecute()
|
||||
|
||||
def btnCancel_clicked( self, oActionEvent ):
|
||||
self.win.endExecute()
|
||||
|
||||
def btnChange_clicked(self,oActionEvent):
|
||||
aVal=[]
|
||||
url= self.win.getEditText("txtHost")
|
||||
Change(aVal,url)
|
||||
if aVal[1]== -1:
|
||||
self.win.getEditText("lstDatabase")
|
||||
self.win.removeListBoxItems("lstDatabase", 0, self.win.getListBoxItemCount("lstDatabase"))
|
||||
self.win.setEditText("txtHost",aVal[0])
|
||||
for i in range(len(aVal[1])):
|
||||
self.lstDatabase.addItem(aVal[1][i],i)
|
||||
elif aVal[1]==0:
|
||||
ErrorDialog(aVal[0],"")
|
||||
else:
|
||||
self.win.setEditText("txtHost",aVal[0])
|
||||
self.win.removeListBoxItems("lstDatabase", 0, self.win.getListBoxItemCount("lstDatabase"))
|
||||
for i in range(len(aVal[1])):
|
||||
self.lstDatabase.addItem(aVal[1][i],i)
|
||||
|
||||
def btnPrevious_clicked(self,oActionEvent):
|
||||
self.win.endExecute()
|
||||
Change(None)
|
||||
|
||||
|
||||
if __name__<>"package" and __name__=="__main__":
|
||||
ServerParameter(None)
|
||||
|
||||
Reference in New Issue
Block a user