Outputting variables values to OpenERP server log - odoo

I am doing a lot of enhancements on an existing OpenERP module. I need to be outputting variables(like queries, calculated values, etc) somewhere (maybe the server log or elsewhere) to see what they actually contain. Please how do I go about doing this?

I run the server in Eclipse with the PyDev plugin. It lets you set breakpoints, step through the code, and examine variable values. You can see more setup details in this answer.

You can use simple print statement in your piece of code in addons and when you start your server you will see the print values on the server log or on terminal. And for advanced debugging of the server values you use python pdb module e.g.
import pdb
pdb.set_trace() #Setting the break point
With this you can do debugging in server execution environment.
Thank You

Related

Hide/cancel the "No data sources are configured to run this SQL" message in Intellij

I could not find any way to hide this warning in Intellij:
No data sources are configured to run this SQL and provide advanced code assistance
What is the magic combination of settings to make this go poof?
There does not appear to be any setting that actually works. Instead it's actually pretty easy to create a "fake" sql source.
Click on Configure data source link in upper right
Select "SQL" (generic one)
Don't worry about the (bogus) connection parameters: just go ahead and "Save" it
The fake connection will not cause issues and now the SQL will be parsed and that message goes .. poof !

Update changes from Developement instance to Production instance in Odoo

I have 2 instances of Odoo v9 running in the same server (Ubuntu 14.04). I want to make changes (install modules, change source code or anything) in the developement instance and after confirming they are OK, move the changes to the Production Instance. Is there anyway of doing that without repeating the whole process of development?
Thank you.
As I can understand you do not want to stop the production instance.
If they are only XML files you might be able to get away by only updating the module from the frontend (Apps-> Your Module -> Update. Although if you have modified the __openerp__.py file inside your module you have to enter the debug mode and click Update Apps List first of all.
For changes in files that are inside the static folder of your module, you do not need to stop the server. Although, your users must click ctr + shift + R in order to flush their caches and bring to their browsers the new content.
For Python source code I am afraid that you have to stop both instances of the server so that the code can be correctly recompiled.
(See note 1 on this)
In the end you should stop and update everything because unexpected things might pop up at random times due to resources not been properly updated.
Note 1: The Python documentation about the compilation of Python modules above others mentions:
As an important speed-up of the start-up time for short programs that
use a lot of standard modules, if a file called spam.pyc exists in the
directory where spam.py is found, this is assumed to contain an
already-“byte-compiled” version of the module spam. The modification
time of the version of spam.py used to create spam.pyc is recorded in
spam.pyc, and the .pyc file is ignored if these don’t match.
So theoretically if you modify fileA.py in a module and a new fileA.pyc is generated the server will be able to interpret and use it. In any case I had an issue with two instances running where the py file was creating the field and the XML file was using it and the server reported that a filed had not been created for the XML view, that means that the server did pick up and parse the XML file but did not recompile the py.

SoapUI - Increase property value for each test case

I want to use a property ('currentId') which has a certain start value. For each test case the value should be increased by 1. I can do that by adding an extra test step in each test case which increases the value but that would be much copy paste. The code for that would be (see reference):
def uniqueUserPortion = testRunner.testCase.testSuite.project.getPropertyValue("currentId")
// convert it to an Integer, and increment
def uniqueUserPortionInc = uniqueUserPortion.toInteger() + 1
// set the property back as string
testRunner.testCase.testSuite.project.setPropertyValue("currentId", uniqueUserPortionInc.toString())
To avoid that copy&paste I've added the code above to the Load Script of the project but it doesn't work:
testSuite.testCases.each {
*code above*
}
What can I do to use the code in one script/call for all test cases?
I could define the property as the start value plus the test case ID but that would be a definition in each test case again since I can not reference the #TestCase#ID in project level/property.
Issue with what your are trying
Load Script of the project is executed once when you import the project into soapui workspace. So, this approach does not work.
As you rightly mentioned, either you need to have it in a separate step of the each test case or you can add the same code as setup script. Yes, it is copy paste only
It is possible to achieve easily using SoapUI NG which pro edition using Event feature.
Then your next question may be : how to do it in Open Source edition of SoapUI.
Here is an soapuiExtensions which I did sometime ago which allows you do the same without having to copy paste for each test case in open source edition.
All you need do is have your groovy script into a specific file called 'TestCaseBeforeRun.groovy'. That means, the script is executed before running each test case.
For more details refer README
This soapuiExtensions library allows users to have some additional functionality in soapUI(free edition) tool, like soapui pro allows to do something before, after doing something.
For eg: User may want to do something before running a test case or after running a test case etc by implementing appropriate groovy script as required. Allow me to add an example here. Usually user may want to add credentials for the request step automatically, see the script samples/scripts/TestSuiteTestStepAdded.groovy
How to use this library:
set SOAPUI_HOME environment variable.
copy lib/SoapUIExtListeners.jar file under $SOAPUI_HOME/bin/ext directory
copy samples/listeners/custom-listeners.xml file under $SOAPUI_HOME/bin/listeners directory
copy samples/scripts directory under $SOAPUI_HOME
And implement appropriate groovy script available under $SOAPUI_HOME/scripts. Refer Mappings file in order to implement respective groovy script.
Note: for windows users, you may need to check %SOAPUI_HOME%\bin\soapui.bat which actually overwrites SOAPUI_HOME, need to fix soapui.bat script if requires.
Uses jdk 7, soapUI 4.5.1, and groovy 1.8.9
Dependency
log4j
UPDATE: this is realted to the note in the above.
As it was mentioned in the note, soapui.bat overrides SOAPUI_HOME environment variable on windows, needs to be tweaked a bit. May be you want to copy that groovy file under %SOAPUI_HOME%\bin\scripts (this is without tweaking soapui.bat)and retry. If your machine is linux then it should work if you copy the groovy file under $SOAPUI_HOME/scripts directory

SSIS Clear configuration variables values after package run / before saving

I have some SSIS packages that connect to an Oracle database. The connection parameters are stored in a SQL database and retrieved by using the Package Configuration tool.
My problem is that the variable that gets populated automatically by SSIS with the configuration string does not get emptied after the package is run. As a result, the value of the variable get saved in the source code when the package is saved. I DO NOT want to have this variable value saved in my source files.
Any idea on how to prevent this from happening?
Thanks!
You can try setting the variable in a package configuration. The way you do this is simple.
First go to the top most layer of your package and right click on the empty space and select package configurations. Choose to add add. Give a location and name for the file and then click next.
Once you've done that choose the variable you want and set the value like this.
Now you're not storing the actual value in the package. Just the information for how to find it.
EDIT: I may not have been clear on this. This process will create a completely separate file that the package will look to to get that expression. This way you don't have to store the expression or the value in the package itself. It just knows at run time to go look for that config file for any additional data.
EDIT 2: The package configuration will only overwrite when you execute the package in BIDS over Visual Studio. The reason this happens is because the package evaluates and then saves prior to run time. This does not happen when you are using SQL agent to run a package and therefore will not store the value or the expression in the source code. I hope I have clarified that for you.

The pprof heap report displays raw memory addresses

Following this guide http://golang.org/pkg/net/http/pprof/, i'm trying to look at the heap report. When i navigate to the appropriate url, this is what is displayed:
I tried this with ActivePerl, StrawberryPerl and the Perl coming with MSYS tools. What is the issue here?
The output of the net/http/pprof package is best used with go tool pprof. If your server is listening on port 6060, you'll want a command like go tool pprof http://localhost:6060/debug/pprof/heap. There's an explanation of how to use the pprof tool at http://blog.golang.org/profiling-go-programs, which is linked from the net/http/pprof package docs.
If you're really interested in trying to read the output yourself, you can add ?debug=1 to the url you tried before - but I can't recommend it.