Siirry sisältöön
Odoo Menu
  • Kirjaudu sisään
  • Kokeile ilmaiseksi
  • Sovellukset
    Talous
    • Kirjanpito
    • Laskutus
    • Kulut
    • Datataulukot (BI)
    • Asiakirjat
    • Allekirjoita
    Myynti
    • CRM
    • Myynti
    • Kassajärjestelmä myymälään
    • Kassajärjestelmä ravintolaan
    • Tilaukset
    • Vuokraus
    Verkkosivut
    • Verkkosivun Rakennustyökalu
    • Verkkokauppa
    • Blogi
    • Foorumi
    • Livechat
    • Verkko-oppiminen
    Toimitusketju
    • Varastointi
    • Tuotanto
    • Tuotteen elinkaaren hallinta (PLM)
    • Ostot
    • Huolto
    • Laatu
    Henkilöstöhallinto
    • Työntekijät
    • Rekrytointi
    • Vapaat
    • Arvioinnit
    • Suositukset
    • Kuljetuskalusto
    Markkinointi
    • Somemarkkinointi
    • Sähköpostimarkkinointi
    • Tekstiviestimarkkinointi
    • Tapahtumat
    • Markkinoinnin automaatio
    • Kyselyt
    Palvelut
    • Projekti
    • Työaikakirjaukset
    • Kenttähuolto
    • Asiakaspalvelu
    • Suunnittelu
    • Ajanvaraukset
    Tuottavuus
    • Viestintä
    • Hyväksynnät
    • IoT
    • IP-puhe
    • Tietokirjasto
    • WhatsApp
    Kolmannen osapuolen sovellukset Odoo-Studio Odoo-Pilvialusta
  • Toimialat
    Vähittäiskauppa
    • Kirjakauppa
    • Vaatekauppa
    • Huonekaluliike
    • Ruokakauppa
    • Laitteistokauppa
    • Lelukauppa
    Ruoka & Majoitus
    • Baari ja Pubi
    • Ravintola
    • Pikaruoka
    • Majatalo
    • Juomien jakelija
    • Hotelli
    Kiinteistöt
    • Kiinteistönvälitystoimisto
    • Arkkitehtitoimisto
    • Rakentaminen
    • Kiinteistönhallinta
    • Puutarhanhoito
    • Kiinteistön omistajien yhdistys
    Konsultointi
    • Tilitoimisto
    • Odoo-kumppani
    • Markkinointitoimisto
    • Lakitoimisto
    • Osaajahankinta
    • Tilintarkastus & sertifiointi
    Tuotanto
    • Tekstiili
    • Metalli
    • Huonekalut
    • Ruoka
    • Panimo
    • Yrityslahjat
    Terveys & Liikunta
    • Urheiluseura
    • Silmälasiliike
    • Kuntokeskus
    • Hyvinvointialan ammattilaiset
    • Apteekki
    • Kampaamo
    Kaupat
    • Yleismies
    • IT-laitteisto & Tuki
    • Aurinkoenergiajärjestelmät
    • Suutari
    • Siivouspalvelut
    • LVI-palvelut
    Muut
    • Voittoa tavoittelematon järjestö
    • Ympäristötoimisto
    • Mainostaulujen vuokraus  
    • Valokuvaus
    • Leasing-pyörät
    • Ohjelmistojen jälleenmyyjä
    Selaa kaikkia toimialoja
  • Yhteisö
    Opi
    • Kurssit
    • Dokumentaatio
    • Todistukset
    • Koulutus
    • Blogi
    • Podcast
    Kannusta kouluttautumaan
    • Koulutusohjelmat
    • Scale Up! Liiketoimintapeli
    • Vieraile Odoolla
    Hanki ohjelmisto
    • Lataa
    • Vertaile versioita
    • Julkaisut
    Tee yhteistyötä
    • Github
    • Foorumi
    • Tapahtumat
    • Käännökset
    • Ryhdy kumppaniksi
    • Kumppanipalvelut
    • Rekisteröi tilitoimistosi
    Hanki palveluja
    • Löydä kumppani
    • Löydä kirjanpitäjä
    • Varaa asiantuntijatapaaminen
    • Implementaatiopalvelut
    • Asiakasreferenssit
    • Tuki
    • Versionkorotukset
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Varaa demo
  • Hinnoittelu
  • Asiakaspalvelu

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

  • CRM
  • e-Commerce
  • Kirjanpito
  • Varastointi
  • PoS
  • Projekti
  • MRP
All apps
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Kaikki kirjoitukset Ihmiset Merkit
Tunnisteet (Näytä kaikki)
odoo accounting v14 pos v15
Tietoa tästä foorumista
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Kaikki kirjoitukset Ihmiset Merkit
Tunnisteet (Näytä kaikki)
odoo accounting v14 pos v15
Tietoa tästä foorumista
Apua

How to get a Python shell with the Odoo environment?

Tilaa

Saat ilmoituksen, kun tähän viestiin ilmaantuu aktiviteettia

Tämä kysymys on merkitty
pythonclishell
9 Vastaukset
69921 Näkymät
Avatar
Kasper Souren

How to get a Python shell with the Odoo environment?

Ideally IPython.

I don't have a clear idea what I want to achieve but over the years I've come to love the possibility of Python (and JavaScript, as opposed to PHP) to just be in a shell with all the relevant code and figure out things. Much better way to learn and code than reading a book or even API documentation.

I started playing around a bit.

    $ ipython

    import openerp

    openerp.cli.main()

5
Avatar
Hylkää
Hannes Smit

Kasper, may I ask what you want to achieve? `python openerp-server` should do start the server. Have a look at the help for flags / configurations.

Avatar
Bernardo Kyotoku
Paras vastaus

In version 10: ./odoo-bin shell -d <database>  --addons-path='your/addons/path'

http://stackoverflow.com/questions/34293139/how-to-run-odoo-orm-methods-in-the-python-console

6
Avatar
Hylkää
Avatar
Marvin Taboada
Paras vastaus

Hello Kasper,

It seems you're using a source distribution where all addons have been moved out of the "openerp.addons" Python package to the root directory of the distribution (current layout in GitHub, branch 7.0), hence it cannot load some required modules. Specifying "--addons-path/addons_path" is required in order to fix this.

You can fake command line arguments in the Python interactive interpreter in the following way:

>>> import sys
>>> import openerp
>>>
>>> sys.argv = ['', '--addons-path=/opt/openerp/server/addons', '--log-level=debug']
>>>
>>> openerp.cli.main()

Please note that the first argument is an empty string.

Regards.

1
Avatar
Hylkää
Avatar
Muhammad Awais
Paras vastaus

 You can also use...           

  • $ python3 odoo-bin shell -d db_name

1
Avatar
Hylkää
Avatar
Wouter Tebbens
Paras vastaus

Hey Kasper, have a look at this thread, it's precisely about IDE's that people use for OpenERP v7 / odoo development:

https://www.odoo.com/forum/Help-1/question/Tools--IDE-for-OpenERP7-source-and-report-development-5536

0
Avatar
Hylkää
Avatar
Jérémy Kersten (jke)
Paras vastaus

Not compatible with V7, because it's new in saas-6...

But that can help other peoples looking about it...

./odoo.py shell -d saas6

after, all is possible ...

OLD API : 

 >>> blog_post_ids = env.registry['blog.post'].search(env.cr, env.uid, [], context=env.context)
>>> env.registry['blog.post'].browse(env.cr, env.uid, blog_post_ids, context=env.context).mapped('name')

[u'The Future of Emails', u'Integrating your CMS and E-Commerce']


NEW API:

>>> env['blog.post'].search([]).mapped('name')

[u'Integrating your CMS and E-Commerce', u'The Future of Emails']

0
Avatar
Hylkää
Avatar
john doe
Paras vastaus

Same situation, shell module is installed. When i type sudo ./odoo.py shell -d v8dev it says:

"ERROR ? openerp.sql_db: Connection to the database failedTraceback (most recent call last): OperationalError: IMPORTANR  "root" role is not exist"

Fix: type just ./odoo.py shell -d v8dev

0
Avatar
Hylkää
Avatar
Manuel A. Márquez
Paras vastaus

I know it's too late but you can use erppeek. https://erppeek.readthedocs.io/en/latest/

0
Avatar
Hylkää
Avatar
Nehemias Herrera
Paras vastaus

Hi, I am trying to get to the interactive shell with odoo 11 but I am getting the error

odoo@21ad17f724ce:/$ odoo shell -d universidad

2018-01-07 18:53:39,951 134 INFO ? odoo: Odoo version 11.0-20171030

2018-01-07 18:53:39,952 134 INFO ? odoo: Using configuration file at /etc/odoo/odoo.conf

2018-01-07 18:53:39,952 134 INFO ? odoo: addons paths: ['/var/lib/odoo/addons/11.0', '/mnt/extra-addons', '/usr/lib/python3/dist-packages/odoo/addons']

2018-01-07 18:53:39,953 134 INFO ? odoo: database: default@default:default

2018-01-07 18:53:39,963 134 INFO ? odoo.service.server: Initiating shutdown

2018-01-07 18:53:39,963 134 INFO ? odoo.service.server: Hit CTRL-C again or send a second signal to force the shutdown.

2018-01-07 18:53:39,964 134 INFO ? odoo.sql_db: Connection to the database failed

Traceback (most recent call last):

File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 59, in __new__

return cls.registries[db_name]

File "/usr/lib/python3/dist-packages/odoo/tools/func.py", line 68, in wrapper

return func(self, *args, **kwargs)

File "/usr/lib/python3/dist-packages/odoo/tools/lru.py", line 44, in __getitem__

a = self.d[obj].me

KeyError: 'universidad'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/usr/bin/odoo", line 8, in <module>

odoo.cli.main()

File "/usr/lib/python3/dist-packages/odoo/cli/command.py", line 60, in main

o.run(args)

File "/usr/lib/python3/dist-packages/odoo/cli/shell.py", line 124, in run

self.shell(config['db_name'])

File "/usr/lib/python3/dist-packages/odoo/cli/shell.py", line 110, in shell

registry = odoo.registry(dbname)

File "/usr/lib/python3/dist-packages/odoo/__init__.py", line 76, in registry

return modules.registry.Registry(database_name)

File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 61, in __new__

return cls.new(db_name)

File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 73, in new

registry.init(db_name)

File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 141, in init

with closing(self.cursor()) as cr:

File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 472, in cursor

return self._db.cursor()

File "/usr/lib/python3/dist-packages/odoo/sql_db.py", line 634, in cursor

return Cursor(self.__pool, self.dbname, self.dsn, serialized=serialized)

File "/usr/lib/python3/dist-packages/odoo/sql_db.py", line 178, in __init__

self._cnx = pool.borrow(dsn)

File "/usr/lib/python3/dist-packages/odoo/sql_db.py", line 517, in _locked

return fun(self, *args, **kwargs)

File "/usr/lib/python3/dist-packages/odoo/sql_db.py", line 585, in borrow

**connection_info)

File "/usr/lib/python3/dist-packages/psycopg2/__init__.py", line 164, in connect

conn = _connect(dsn, connection_factory=connection_factory, async=async)

psycopg2.OperationalError: could not connect to server: No such file or directory

Is the server running locally and accepting

connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?


I tried from the official odoo docker image and also with bitnami odoo image, same error, I am able to get into it without the -d argument but this way there's no environment, how can I either start the interactive shell properly or how to load the environment if I got into the interactive shell whitout specifying at database.

there's another error

odoo@21ad17f724ce:/$ odoo shell

2018-01-07 18:58:41,137 149 INFO ? odoo: Odoo version 11.0-20171030

2018-01-07 18:58:41,137 149 INFO ? odoo: Using configuration file at /etc/odoo/odoo.conf

2018-01-07 18:58:41,137 149 INFO ? odoo: addons paths: ['/var/lib/odoo/addons/11.0', '/mnt/extra-addons', '/usr/lib/python3/dist-packages/odoo/addons']

2018-01-07 18:58:41,137 149 INFO ? odoo: database: default@default:default

2018-01-07 18:58:41,148 149 INFO ? odoo.service.server: Initiating shutdown

2018-01-07 18:58:41,148 149 INFO ? odoo.service.server: Hit CTRL-C again or send a second signal to force the shutdown.

No environment set, use `/usr/bin/odoo shell -d dbname` to get one.

odoo: <module 'odoo' from '/usr/lib/python3/dist-packages/odoo/__init__.py'>

openerp: <module 'odoo' from '/usr/lib/python3/dist-packages/odoo/__init__.py'>

Python 3.5.3 (default, Jan 19 2017, 14:11:04)

[GCC 6.3.0 20170118] on linux

Type "help", "copyright", "credits" or "license" for more information.

(Console)

>>> dir()

['__builtins__', 'odoo', 'openerp']

>>> from odoo.service import db

>>> db.list_dbs()

2018-01-07 18:59:15,171 149 INFO ? odoo.sql_db: Connection to the database failed

Traceback (most recent call last):

File "<console>", line 1, in <module>

File "/usr/lib/python3/dist-packages/odoo/service/db.py", line 362, in list_dbs

with closing(db.cursor()) as cr:

File "/usr/lib/python3/dist-packages/odoo/sql_db.py", line 634, in cursor

return Cursor(self.__pool, self.dbname, self.dsn, serialized=serialized)

File "/usr/lib/python3/dist-packages/odoo/sql_db.py", line 178, in __init__

self._cnx = pool.borrow(dsn)

File "/usr/lib/python3/dist-packages/odoo/sql_db.py", line 517, in _locked

return fun(self, *args, **kwargs)

File "/usr/lib/python3/dist-packages/odoo/sql_db.py", line 585, in borrow

**connection_info)

File "/usr/lib/python3/dist-packages/psycopg2/__init__.py", line 164, in connect

conn = _connect(dsn, connection_factory=connection_factory, async=async)

psycopg2.OperationalError: could not connect to server: No such file or directory

Is the server running locally and accepting

connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

>>>

Any help will be appreciated :) thanks




-2
Avatar
Hylkää
Nautitko keskustelusta? Älä vain lue, vaan osallistu!

Luo tili jo tänään nauttiaksesi yksinoikeusominaisuuksista ja osallistuaksesi mahtavaan yhteisöömme!

Rekisteröidy
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
how to install CLI shell in odoo?
cli shell v8.0
Avatar
Avatar
Avatar
5
helmik. 17
11008
new python env
python
Avatar
0
maalisk. 25
2390
What means "Too many values to unpack" message? Ratkaistu
python
Avatar
Avatar
Avatar
Avatar
Avatar
4
huhtik. 24
175951
have no data in screen. read data in my own module from different model
python
Avatar
0
jouluk. 23
3009
How to insert value to a one2many field in table with create method? Ratkaistu
python
Avatar
Avatar
Avatar
Avatar
Avatar
5
heinäk. 25
232395
Yhteisö
  • Kurssit
  • Dokumentaatio
  • Foorumi
Avoin lähdekoodi
  • Lataa
  • Github
  • Runbot
  • Käännökset
Palvelut
  • Odoo.sh hosting
  • Tuki
  • Versionkorotus
  • Räätälöidyt kehitykset
  • Koulutus
  • Löydä kirjanpitäjä
  • Löydä kumppani
  • Ryhdy kumppaniksi
Meistä
  • Yrityksemme
  • Brändiominaisuudet
  • Ota yhteyttä
  • Työpaikat
  • Tapahtumat
  • Podcast
  • Blogi
  • Asiakkaat
  • Oikeudellinen ilmoitus • Yksityisyys
  • Tietoturva
الْعَرَبيّة 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 on kokoelma avoimen lähdekoodin yrityssovelluksia, jotka kattavat kaikki yrityksesi tarpeet: asiakkuudenhallinta eli CRM, verkkokauppa, kirjanpito, varastointi, kassajärjestelmä, projektinhallinta, jne.

Odoon uniikki arvolupaus on olla samanaikaisesti erittäin helppokäyttöinen ja täysin integroitu.

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