I am developing a custom module for Odoo in WIndows. Everything is working fine, but I find that the way to make changes to my code a bit tedious and I thought I would ask the experts here to help me make it faster.
Currently, everytime I make modification to my code, I do the following steps to test the outcome:
1) In Odoo, I go to Settings>Local Modules> My App and click "Uninstall"
2) In Windows, I remove the modules folder from the "addons" directory and replace it with the new modified version.
3) I go to Windows> Control Panel> Administrative Tools > Services and I restart both the "PostgreSQL_for Odoo" service as well as the "Odoo-server" service
4) In Odoo, I click on Settings> Update Modules List
5) I then go to Settings> Local Modules> My App and click "Install"
As you can see, this is a lengthy process, but this is the only way I found that works. It gets to be frustrating when the change in code is only an indentation or a forgotton comma :-)
If I just click to "Upgrade" my module, I usually get various errors like "Internal Server Error" or "getitem" key errors. Also, if I don't restart both services above, odoo does not load the changes in the python code.
So, is there a "proper way" to upgrade a module or even modify the code directly while Odoo is running?
thanks in advance
@Abdullah, you shouldn't Uninstall modules for upgrade. It may removed existing data. What you should do is
- Update the module that you want to upgrade in the addons folder
- Restart the Odoo-server service (unfortunately this is still necessary as python need to create the compiled version of the py files).
- If you have new modules, click the Setting >> Modules >> Update Module List menu and follow through
- Then from Setting >> Modules >> Installed Modules, select the modules you just updated, and click on Upgrade button.
Note that 2 is required if you change any of the py files. If you don't change py files, you can skip it. Yes, some error may occurs if you radically change the structure of model in the update module. Hence, it is better not to remove any existing fields or change their type.
Note on 4: if you don't change any data files (XML or CSV) included in the module and you don't change any model structure (no fields or defaults or sql_constraint or constraint [etc....] added/removed/modified) and only change method implementation, you may get away without doing 4.
Additional Note: if you define a data record in the old version of the module and you don't require it anymore int he new version of the module, add a <delete model="model_id" id="xml_id_of_record_to_delete"/> into the XML file to properly remove the data.
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
|Asked: 12/22/14, 2:38 AM|
|Seen: 1578 times|
|Last updated: 3/16/15, 8:10 AM|