Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

How to access to the ORM from outside properly ?

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
pythonormpool
1 Odpowiedz
8040 Widoki
Awatar
PY

Hello !

I have to access to the ORM of openERP 7 from a python script.

I tried:

>>> import openerp

>>> pool = openerp.pooler.get_pool('test')

No handlers could be found for logger "openerp.modules.module"

>>> my_obj = pool.get('my_obj')

>>> type(my_obj)

<type 'NoneType'>

As you can see, I can't access to custom objects (e.g. tables) from outside. I've listed all the objects in the pool via pool.obj_list(), and it seems that the list is too short, even including official modules that are installed.

So, how can I access to all the objects that represents the tables of my database 'test' ?

Thanks !

PS: I can do stuff via XMLRPC instead, but I would like to use the ORM, because it's faster (already tested it).

EDIT: No one ?

Here's a more detailed example :

import openerp
import sys
sys.path.append("/home/openerp/custom_addons")
import synconfig

DBNAME = "test"
uid = 1

cr = openerp.sql_db.db_connect(DBNAME).cursor()
pool = openerp.pooler.get_pool(DBNAME)

ir_model = pool['ir.model']
data = ir_model.search(cr, uid, [])
print 'data from ir.model: %d' % len(data)

my_object = pool['my.object']
data = my_object.search(cr, uid, [])
print 'data from my.object: %d' % len(data)

Output :

data from ir.model: 334
Traceback (most recent call last):
  File "./orm_outside.py", line 20, in <module>
    my_object = pool['my.object']
  File "/home/openerp/server/openerp/modules/registry.py", line 102, in __getitem__
    return self.models[model_name]
KeyError: 'my.object'

0
Awatar
Odrzuć
Awatar
Ivan
Najlepsza odpowiedź

AFAIK, I don't think you can use ORM outside OpenERP without having to recreate the whole framework first.

What are you trying to achieve by accessing the ORM outside the framework?  Can it be performed within the framework instead?

1
Awatar
Odrzuć
PY
Autor

Hi ! I have a socket server that will receive asynchronous responses from a previous request made inside the ORM. I can handle the asynchronous response with XMLRPC, but the ORM beeing faster, that's why I would like to use it. And also, I'm curious to know why I can access the basic modules, and not the others. Oh, and the request being asynchronous, it cannot, of course, be handled inside the ORM.

Ivan

There are facilities such as Automated Actions and Scheduled Actions that can be used to perform asynchronous processes. As I mentioned, you need to recreate the supporting structure of the ORM first before using the ORM outside. OpenERP created a special namespace which is used for importing stuff within OpenERP. If you check the openerp/osv/orm.py file, on the top you'll find lines such as import openerp.netsvc, etc. So to use orm.py file, you need to have those files as well located at the path as specified (and so on, you need to trace the other imports that are needed by those imported files respectively). I haven't tried this, but maybe installing OpenERP using the binary package might help as if you install OpenERP using binary package, it will be stored within the PYTHON PATH.

PY
Autor

The python path isn't a problem, because I can include my addons folders in sys.path, then import a custom addon. However, that does not solve the problem, the pool does not contain the custom addon's objects.

Ivan

PY, sys.path is different from PYTHON PATH.

PY
Autor

I think I understand a little better. I think it's the instanciation of the pool that the addons must be added, but how, I will need to find out. (On a side note, I already now how to fix my code with xmlrpclib, so from this point, this question is just curiosity ^^)

Ivan

Congratulation PY. It would be great if you can share what you have learned with all of us. And yes, the instanciation of the objects in addons and especially base must be proper to create a proper OpenERP environment.

PY
Autor

Pfff, this is a mess... I've been reading the code for more than an hour now, and I think I will pass for today ^^ I've learned a lot, but not enough. However, I will accept your answer, since it's not so easy to do it. People (including me) would be better served with xmlrpc. Thanks anyway !

Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
How to get attribute from another class using the browse method in OpenERP ? Rozwiązane
python orm browse pool
Awatar
Awatar
2
mar 15
18560
Get author_id from mail_message in openERP
python orm
Awatar
Awatar
1
mar 15
6573
ORM .browse method returns objects even if the ids do not exist on the database Rozwiązane
python code orm
Awatar
Awatar
2
lip 22
6401
How i can apply filter into record ?
filter python orm
Awatar
Awatar
1
wrz 19
2873
Add a model into a pre-existant module (getting need more than 1 value to unpack error)
python pricelist pool
Awatar
0
wrz 15
4574
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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