Update changes from Developement instance to Production instance in Odoo - 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.

Related

How allow only one python code process to run if same is executed at the same time

if I have two or more running python console applications at the same time of same application, but executed several times by hand or any other way.
Is there any method from python code itself to stop all extra processes, close console window and keep running only one
The solution I would use would be to have a lockfile created in the tmp directory.
The first instance would start, check for the existence of the file, create the file since it is not there, then run; the following instances will start, check for the existence of the file, then quit since it's there. The original instance would remove the lockfile as its last instruction. NOTE: If the app runs into an error and does not execute the instruction to remove the lockfile, you would need to manually remove it else the app will always see the file.
I've seen on other threads that some suggest using the ps command and look for your app's name, which would work; however, if your app will ever run on Windows, you would need to use tasklist.

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

IBM Urbancode Deploy - Supply values to parameters at runtime using properties

I have created a process in IBM UCD to deploy a .Net application.
My Scenario is that i should be able to provide different application name at run time each time i run the process. How can we do this using property in IBM UCD.
I have tried enabling "Prompt on use" option and also created component property and mapped it to the parameter say ${p:component/application.name} but doesn't seem to work. May be i missing out some sequence of steps.
It would be great if i get detailed steps to making this working.
I take it that you are on version 4.x (uDeploy)?
I would steer clear of the prompt on use approach, that feature was removed in 6.x. While there is a migration in place, its simpler to just avoid it.
Using a property on the component process itself is the way to go. So go to your process configuration, and go to the properties / configuration tab. Create a property there. You'll be prompted for a value whenever you run an application process that uses this component process.
If the property is named "iis.app.name" you would reference it with just ${p:iss.app.name}.
Don't use the property "application.name". That is an automatically created property that gets the name of the UCD Application that you are deploying. If you ever can't find out the right way to reference a property, look at your executed process (at component / application levels). The normal view that lists out all the steps that were run and how long they took is sitting on a tab called "Log". Right next to it is "Properties" tab. Click that and you'll see what properties were available to the process.
Also, you'll have better luck getting fast answers about UC Deploy using their own forum: https://developer.ibm.com/answers/?community=urbancode
Did you tried using process plugin for updating the property file ?
Application >> Process >> Select Process >> Process Editor -- From left panel you can Utility plugins , try with update property option.

Custom Building Block Template wont load reliably

My small collection of document-specific macros and quickpart building blocks is growing! I'm starting to share these with employees, and am looking to be able to set up each remote computer once only. From there on, update collections on a network path. And because each computer looks to the shared location, everyone should always be working with up to date macros and quickparts etc.
So. What I already know:
- Required macros are saved in a separate module, ready to be shared/exported.
- Macros themselves occasionally reference local paths on my computer.
- I will need to reference paths with generic code or use Environ variables.
- Building blocks and quickparts are saved in a separate template file (currently located in Appdata, along with default building block file).
What I dont know:
a) How to point Word to a network path to retrieve macros from custom macro files. (Would I just have to import a fresh macro file at every important update, on each PC?)
b) What's the best way to load a building block item from a CUSTOM path?
My custom BuildingBlock template file is not loaded properly on occasion:
Dim objTemplate As Template
Dim objBB As BuildingBlock
'set template to store the building block
Set objTemplate = Templates("C:\Users\[USER]\AppData\Roaming\Microsoft_
\Document Building Blocks\1033\CustomBBlocks.dotx")
Set objBB = objTemplate.BuildingBlockEntries.Item("[EntryName]")
I know this because the code spits out a 'CollectionDoesntExist' error unless I click the Quickparts gallery prior to running the code for the first time. So it's like Word cant be bothered to open the template file and look inside unless I do it from the UI first.
Of course, if I first open the Quickparts gallery from the UI, prior to running my code, Word seems to figure it out, and inserts the correct Building Block entry without any issue.
In the past I've worked on a product that allows building blocks for Word too. Some sites have hundreds of templates and maybe 1.000 elements (see Composition). The approach we've taken was successful and was different.
You are trying to deploy software elements (macros) across a large number of workstations. You can try to get it working using the possibilities of Microsoft Word and Windows, but it will be sensitive to problems when things change. For instance, switching to Office 2013, splitting a domain into two, work at home without VPN, etc.
Option 1 - DIY deployment: Better put the macros and other stuff behind a webpage, webservice or alike. Deploy on each workstation a generic program that pulls in everything and deploys it locally. You might want to hand over some parameters to the webpage being called to restrict the amount of data. You might want to cache things locally.
Option 2 - Use ClickOnce: write a clickonce deployment script, include the necessary references and put it on a shared network drive or http address. ClickOnce automagically upgrades your software when it finds a new version. It even works across the internet. And it does nothing when there is no new version.
Option 3 - Database: put the elements centrally in a database, allowing end users to change building blocks through forms. Have Microsoft Word in combination with a ClickOnce program pull them in.
For Composition we've used option 2 and 3.

OpenERP: modify core module

I'm new to OpenERP and Python too. I have OpenERP 6.0.4
I have modified the invoice.py file in the account folder using python 2.7 (I just edited and saved the file, I didn't compile anything).
The change I made is how the total amount is calculated, I needed the total amount to always add 0.3 EUR to the total.
I then restarted OpenERP server, I also went to admnisitration>modules> set the account module to upgrade and then applied the upgrades.
I then started a new invoice and the changes were not reflected.
For testing purposes, since I'm new to Python and thought maybe I didn't code correctly, I have modified the help message that appears when you hover the mouse over "Residual" in the invoice interface by modifying a line in invoice.py from help="Remaining amount due." to help="This is just for testing."
I restarted the server and upgraded the modules and even this change isn't reflected.
I even created a new database and the modifications are still not showing.
Am I missing something? Is it even possible to edit the core modules ? Is there any workaround to this?
FINAL SOLUTION : Uninstalling and reinstalling the server solved the problem.
The most probable cause is the the addons directory being used is not the same you are editing. You can be sure if you change the name of the addons directory and can restart the server without problems. You can also try to set the --addons-path parameter to the server start command.
If/when you confirm to be working on the right files, try instead to make small text changes on views, since these are visible right after a module upgrade, not requiring a server restart. For instance, try changing some string attributes on account\partner_view.xml.
Slightly off topic, but important: you should not be modifying the core modules directly in the source. The correct way is to extend the core class in your own module which will depend on the core module.
From your comments, it seems you want to add a set tax amount to your invoice. Have a look at http://doc.openerp.com/v6.1/book/3/3_7/invoicing.html#tax-management - openerp already caters for that need and then you dont need to hack the source code which should be your last resort :)