Skip to Content
Menu
This question has been flagged
3 Replies
15026 Views

Can someone please give idea on how to connect Odoo/OpenERP from PyCharm?

Avatar
Discard
Best Answer

Hello,

May be this will helpful to you.

Go to pycharm inbuilt terminal and login via ssh in that remote odoo server.

Thanks.

Shamji.


Avatar
Discard
Best Answer

This maybe helps you:

http://bloopark.de/blog/the-bloopark-times-1/post/setup-odoo-development-on-os-x-with-pycharm-109



Avatar
Discard
Best Answer

I have solved remote debugging to my remote ubuntu server by doing the following:

On your remote server, run: pip install cython pydevd

IMPORTANT: Make sure that your computer is visible to server's IP by pinging your computer's IP

On your computer, configure a Python Remote Debug in run configurations.

Set Local Host Name: The IP of your computer. Yes, that computer with the pycharm installed.

Set the Port: 7999. Actually, any port will do as long as its above 1000.

Make sure to check the box, SINGLE INSTANCE ONLY


On File>Settings>Execution>Deployment, create an SFTP Server Connection.

Set the SFTP host to the server's IP. set the root path to the installation directory of your odoo server. In my case, its located at /opt/odoo

Set the username and password.

On the mappings tab,

Set the Local Path to your project's directory root

Set the deployment path to "\" or backslash.

Set the web path to "/" or forwardslash.

Test the SFTP connection.


On the server, open the file /opt/odoo/openerp-server (It's a python file without the extension)

Add these statements after the "import openerp"

import pydevd

pydevd.settrace('YOUR COMPUTER IP', port=7999, stdoutToServer=True,stderrToServer=True)


TODO EVERYTIME YOU MODIFY YOUR CODE AND DEBUG THAT

Now to start the debug, add a breakpoint in your code.

Run the remote debug to start listening from the server.

Restart the openerp instance you got running in your server. In my case, I force restart the init.d/odoo-server file:

/etc/init.d/odoo-server restart

If successful, pycharm will light up in the menu bar and ask you to set the path mappings. Just click the autodetect and press Save forever.

Notice that if you visit the odoo server website, it just won't load. Actually, pycharm sets a "virtual" breakpoint after the settrace command you have provided so you have to press the play button thing at the debug(or F8)

Viola! Now it works and any breakpoint you set will stop odoo from executing and let you analyze everything.

Test it by adding a breakpoint in your code and try to run that code. Try the @api.onchange ones since they are more predictable to run.

Avatar
Discard

Hi queeryme,

I'm trying to do the same thing in Odoo 10

I went through your guide and I'm stuck in this step

Add these statements after the "import openerp"

import pydevd

pydevd.settrace('YOUR COMPUTER IP', port=7999, stdoutToServer=True,stderrToServer=True)

in my case in odoo10 I used this file: /opt/odoo/odoo-server/odoo-bin

then added the two lines you mentioned.. Now Odoo isn't starting at all. Can you help me please

I haven't yet started on Odoo 10 but I'll post a complete setup guide for Odoo 9 on CentOS 7 tomorrow. Wait for it.

I will be waiting.. thanks in advance

This is a snippet from my Setup Guide.

1. On XShell/PUTTY, install pip and pydevd for debugging

yum -y install python-pip

pip install --upgrade pip

pip install pydevd

2. On PyCharm, edit _init_.py on the root of the project and add the following:

import pydevd

pydevd.settrace('YOUR IP ADDRESS', port=7999, stdoutToServer=True, stderrToServer=True)

3. Open Menu → Run → Edit Configurations

4. Click on “Add new configuration ”

5. Click on “Python Remote Debug” menu item

6. Set the following details:

a. Name: <Project Name>

b. Local Host Name: <YOUR IP ADDRESS>

c. Port: 7999

d. Path mappings: <Project Path>\<Project Directory> = /usr/lib/python2.7/site-packages/openerp

e. Single Instance Only: checked

7. Click on “OK”

8. To debug, click on Menu → Run → Debug <Project Name>

9. On XShell tab/PUTTY <Project Name>, run the following command:

service odoo restart

10. Click on “Auto-detect path mapping settings” on connect

11. Configure the log file access

sed -r -i -e 's/(logfile = ).*/\1\/var\/log\/odoo\/odoo-server.log/g' /etc/odoo/openerp-server.conf

**** Notes: Make sure to have the whole openerp directory copy as your project directory to load the autocomplete properly. ****