Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
100848 Vistas

I want to configure pycharm in windows so that i could be able to create mudules from scaffold automatically. Then i can code it. Test it. and then run it automatically using run button.

Avatar
Descartar
Autor

Thaaaank you sooooooooooooo much bro. i am going to try it.

Mejor respuesta

Openerp in pycharm:

Create a new project:

File -> New project:

Location: -- Give your location (Similar to eclipse workspace)

Interpreter: python2.7

Adding source content in the new project:

File -> Settings;

In Project:{project_name} tab -> Project structure:

Add content root -> Select your different source folders.

In Appearance & Behaviour:

Keymap: Select Eclipse to get the same shortcut functionality as eclipse.

In Editor -> General -> Appearance: Enable show line numbers for debugging purpose.

Click Apply & Ok.

To create run configuration:

Run --> Edit Configurations, click "+" on the top left to create a new configuration with the following settings:

Name: openerp

Single instance checkbox: checked

Script: /opt/openerp/odoo.py

Script parameters: --config=/openerp-server.conf

Python interpreter: Python 2.7.6 (usr/bin/python2.7)

Working directory: /opt/openerp/pycharm/

To Add VCS integrations:

VCS -> Enable version control integration -> Select Subversion for openerp and Git for odoo incase you're working in git.

You can perform all RabbitVCS operations in pycharm itself.

Add external package:

External Libraries will be automatically loaded when you define interpreter. Incase you need to add extra library means,

Select Project -> File -> Settings -> Project:{project_name} tab -> Project Interpreter -> click "+" on the top left to add new packages.

Customizing Toolbar:

Enable toolbar from View -> Toolbar.

Right click toolbar -> Customize menu and toolbar -> Expand Main Toolbar.

Click any toolbar -> Add after -> Select any menu that needs to be appear in the toolbar.

You can use odoo or openerp, whatever you wish. This is the template i have been using for a while in linux. You could easily change it to windows. Only the source location gonna change.

Scaffold:

To perform scaffold operation pycharm has inbuilt terminal facility. you could go to odoo directory and issue the scaffold command to get it working. I hope you know the command for scaffolding.

Templates:

Usage video link: https://goo.gl/FXpspb

Github source link: https://github.com/mohamedmagdy/odoo-pycharm-templates (find the xml in attachments)

Just find the path: ~/.PyCharm40*/config/templates (in /home/harmony) and save the XML file there.

Invalidate cache and restart pycharm to make it work.

Avatar
Descartar

I followed these steps. But still I cann't import modules from openerp. any help please

Mejor respuesta

I have tried this and there were many obstacles about Python and Windows API. The following are my problem and resolution.

1. You might know that PyCharm automatically run this statement for you.

    pip install -r requirements.txt   

  result:

     missing vcvarsall.bat for making gevent, psycopg2

  To solve this, download and install Microsoft Visual C++ Compiler for Python 2.7 at

https://www.microsoft.com/en-us/download/details.aspx?id=44266

  run this again

pip install -r requirements.txt

  someone recomment to run (I didn't know the reason behind, but I did it)

pip install --upgrade setuptools

2. Make sure you've already installed Postgresql and set your Odoo config file connect to the DB. For example, here is a part of my config file.

    db_host = localhost

    db_maxconn = 64

    db_name = False

    db_password = openpgpwd

    db_port = 5432

    db_template = template1

    db_user = openpg

    pg_path = C:\Program Files (x86)\Odoo 9.0-20160803\PostgreSQL\bin

3. Try to run your Odoo.py on PyCharm. If you encounter psyconpg2 error, try to reinstall it.

    pip uninstall psyconpg2

    pip install psyconpg2

4. The next problem you may have found is about pywin32. Just download and install Python for Windows Extensions at

    https://sourceforge.net/projects/pywin32/

5. Now your odoo.py should be able to run. Optional, if you want to set PyCharm (live)template as mentioned on the first answer. On Windows, the path to put Odoo.xml (template file) is a bit different.
    <your home directory>\.<product name><version number>\config\templates

for example

    C:\Users\John\.PyCharm2016.2\config\templates

if "templates" folder doesn't exist, create one.


My Environment
    OS:           Windows 10 Home 64bit  
    Python:   2.7.12 [MSC v.1500 32 bit (Intel)] on win32 run on 32bit
    Editor:     PyCharm Community Edition 2016.2.2

     Odoo:     9.0 Communication Source from GitHub
Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
3
may 17
9440
2
nov 24
1876
1
nov 23
2287
1
sept 23
3606
0
abr 21
3034