Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Visual Studio Code Debugging Problem

Subscriure's

Get notified when there's activity on this post

This question has been flagged
pythondebuggingodooV12vscode
7 Respostes
36975 Vistes
Avatar
MFDEV
settings.json:
{    
"python.pythonPath": "C:\\VirtualEnvs\\odoov12\\Scripts\\python.exe",
"python.autoComplete.extraPaths": [
        "${workspaceRoot}/odoo/addons",
        "${workspaceRoot}/odoo",
        "${workspaceRoot}/odoo/openerp/addons" ],
        "python.linting.enabled": true,
    "python.linting.pylintArgs": ["--load-plugins", "pylint_odoo"],
    "python.formatting.provider": "yapf",
    "python.linting.pycodestyleEnabled": true,
    "python.linting.pylintEnabled": false,
    "python.linting.pylamaEnabled": true,
    "files.autoSave": "afterDelay",
    "files.autoSaveDelay": 500,
    "files.exclude": {
        "**/*.pyc": true 
                       },
} 

launch.json:
{    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
          {
            "name": "Odoo-Zea",
 "type": "python",
 "request": "launch",
 "stopOnEntry": false,
 "program": "${workspaceFolder}/odoo/odoo-bin",
 "pythonPath": "C:\\VirtualEnvs\\odoov12\\Scripts\\python.exe",
 "args": [
 "--config",
 "${workspaceFolder}/environments/zaeelektronik/zae-odoo.conf",
 "-u",
 "zae_elektoronik",
 "-u",
 "tcmb_currency_rate_live"
 "-d",
 "zae_local",
 ],
 "console": "integratedTerminal",
 },
]
}  

Here is my settings.json and launch.json. I start to debugging (Pressing F5) debugging is started and after 2 sec later debug has finished. The status bar is orange when i m pressing F5 but after that the status bar immadiately blue again. I use Odoo v12. By the way I can develop Odoo using Pycharm. It works on it . But it doesn't work on VS Code. Can you help me ? What I am doing wrong ?

​​ ​

0
Avatar
Descartar
Avatar
krunallathiya21.kl@gmail.com
Best Answer

To debug your app in Visual Studio Code, you’ll first need to set up your launch configuration file - launch.json.
Click on the Configure gear icon on the Debug view top bar, choose your debug environment and Visual Studio Code will generate a launch.json file under your workspace’s .vscode folder.

{
    "name": "Python",
    "type": "python",
    "request": "launch",
    "stopOnEntry": false,
    "pythonPath": "${config.python.pythonPath}",
    //"program": "${file}", use this to debug opened file.
    "program": "${workspaceRoot}/Path/To/odoo.py",
    "args": [
      "-c ${workspaceRoot}/sampleconfigurationfile.cfg"
    ],
    "cwd": "${workspaceRoot}",
    "console": "externalTerminal",
    "debugOptions": [
        "WaitOnAbnormalExit",
        "WaitOnNormalExit",
        "RedirectOutput"
    ]
},

use “args” to specify any options like database, config, or user name and password.

I hope this helps.

0
Avatar
Descartar
krunallathiya21.kl@gmail.com

To install Visual Studio Code check out this guide: https://appdividend.com/2018/03/17/how-to-install-visual-studio-code-on-mac/

Avatar
Khaled
Best Answer

Well, I guess there is better way that there is no need to add code to odoo itself

https://gist.github.com/kerbrose/e646aaf9daece42b46091e2ca0eb55d0

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Odoo: Attach",
            "type": "python",
            "request": "attach",
            "port": 8879,
            "debugServer": 8888,
            "host": "localhost",
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "/mnt/extra-addons", //path to custom addons inside docker
                },
                {
                    "localRoot": "/dev/odoo", //odoo source code
                    "remoteRoot": "/odoo",    //path to source inside docker
                }
            ],
            "logToFile": true
            //"preLaunchTask": "init docker",
            //"postDebugTask": "stop docker"
        }
    ]
}

please note that your docker.dev file should include

RUN pip3 install -U debugpy

then you will be running the debugger not odoo as
docker run --rm -p 8888:3001 -p 8879:8069 odoo /usr/bin/python3 -m debugpy --listen 0.0.0.0:3001 /usr/bin/odoo --db_user=odoo --db_host=db --db_password=odoo
or
docker-compose run --rm -p 8888:3001 -p 8879:8069 odoo /usr/bin/python3 -m debugpy --listen 0.0.0.0:3001 /usr/bin/odoo --db_user=odoo --db_host=db --db_password=odoo
0
Avatar
Descartar
Avatar
Shringar Gupta
Best Answer
Put this in your launch.json file. This worked for me.
{
 "name": "Python: Odoo",     
 "type": "python",           
 "request": "launch",            
"pythonPath": "Give the entire path of python from the virtual environment you are using",            
"console": "integratedTerminal", 
 "program": "${workspaceFolder}/odoo-bin",
 "args": ["start", "--database=Your database name", "--db-filter=Your database name", "-i base",  "--addons-path=Give complete path for yopur addons",            ],
 "cwd": "${workspaceRoot}",
 "env": {},
 "envFile": "${workspaceRoot}/.env",
}
0
Avatar
Descartar
MFDEV
Autor

When I m trying to debug I am getting this error " Could not create database `my database name`. (FATAL: role "Asus" does not exist) ". But my database already exist . I looked for the solution on web but i couldn't find for Windows 10.

ti-sq

This worked for me as well! I just removed the '-i base' command.

Perhaps it could help you as well? What happens if you don't set a database name but only '"args": ["start", "-i base", "--addons-path=Give complete path for yopur addons", ]?

Avatar
Ravi Gadhia
Best Answer

https://www.odoo.com/forum/help-1/question/how-debug-code-from-visual-studio-code-in-docker-container-158277#answer-158296

0
Avatar
Descartar
MFDEV
Autor

It doesn't work for me and I don't understand what you mean.

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Related Posts Respostes Vistes Activitat
custom report does not show data
python odoo12 odooV12
Avatar
0
de nov. 19
3971
self.ensure_one() is not working
python event odooV12
Avatar
Avatar
1
de nov. 19
6815
Debug python code in terminal
debugging Python odooV12
Avatar
Avatar
1
de nov. 19
5440
How to modify the base translate.py file in the odoo/tools folder?
python translation odooV12
Avatar
0
d’ag. 19
4317
group id on different dates
python odoo odoo12 odooV12
Avatar
0
de des. 19
3336
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now