Przejdź do zawartości
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
    • Sztuczna inteligencja
    • IoT
    • VoIP
    • Wiedza
    • 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ą
    • Referral Program
    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
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

What does <field name="model_id" ref="XXXX"> refer to?

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
server_actions
1 Odpowiedz
34902 Widoki
Awatar
Darrel

I'm currently looking at stored server actions in XML. Here is an example of one, from the crm addon:

        <record id="action_mark_as_lost" model="ir.actions.server">
            <field name="name">Mark As Lost</field>
            <field name="model_id" ref="model_crm_lead"/>
            <field name="state">code</field>
            <field name="code">
                if context.get('active_model') == 'crm.lead' and context.get('active_ids'):
                    self.case_mark_lost(cr, uid, context['active_ids'], context=context)
            </field>
        </record>

What is "model_crm_lead?" Odoo generally refers to models by the name defined in the model, so it's referring to the crm.lead model, shouldn't the tag be:

<field name="model_id" ref="crm.lead"/>

I thought perhaps it is using the class name instead of the internal model name (for some reason), and prefacing it with "model_<MODEL_CLASS_NAME>" but I'm only guessing and don't really know how this field works or where it is explained.

Edit: Is it "model_<MODEL_TABLE_NAME>"? It's that isn't it?

0
Awatar
Odrzuć
Awatar
Marvin Taboada
Najlepsza odpowiedź

Hello Darrel, before providing an answer, let me put some background information here.

Background:

At loading data by installing resources (models, fields, model-records, views, record rules, actions, menu entries, etc.), Odoo registers mapping records for all resources in the 'ir_model_data' table ('ir.model.data' object), so we can reference those records later, even from other modules.

Mapping records in 'ir_model_data' have the following remarkable columns:

  • module: module name, string literal (not its id)
  • model: fully-qualified dot-separated object name (also known as the object's technical name)
  • res_id: The resource id/Database ID (the PK of the record in the table where the resource is stored)
  • name: record name, a string literal that in conjunction with the module name uniquely identify the record/resource

The record name in conjunction with the module name form what we know as the resource External ID which has the following fully-qualified form: 'module_name.resource_name'.

Records defined in XML data define their External IDs by means of the 'id' attribute of the 'record' tag.

The 'id' attribute can explicitly include 'module_name.' (fully-qualified form) or not. In the later case (relative form) the module that declares the resource is assumed:
* https://github.com/odoo/odoo/blob/8.0/openerp/tools/convert.py#L707

The above long story was required to have enough background for the answer that follows.

Answer:

At processing child 'field' tags of any 'record' tag, the 'ref' attribute is expected to have the External ID of a referenced existing record (fully-qualified or relative form):
* https://github.com/odoo/odoo/blob/8.0/openerp/tools/convert.py#L727
* https://github.com/odoo/odoo/blob/8.0/openerp/tools/convert.py#L836

Mapping records that reference models are created at initializing modules/models/fields. As they lack a corresponding XML record and cannot declare its corresponding External ID by this means, the ORM creates its External ID based in the 'model_' prefix and the object's technical name (dots replaced by underscores):
* https://github.com/odoo/odoo/blob/8.0/openerp/models.py#L382

This is why records that reference models ('ir.model' records) have the following form: model_XXXXX

Records for some other resources also have known prefixes for their External IDs:

  • Modules: https://github.com/odoo/odoo/blob/8.0/openerp/modules/db.py#L90
  • Models: https://github.com/odoo/odoo/blob/8.0/openerp/models.py#L382
  • Fields: https://github.com/odoo/odoo/blob/8.0/openerp/models.py#L444

SELECT * FROM "ir_model_data" WHERE name LIKE 'module_%'; -- most are 'ir.module.module' records
SELECT * FROM "ir_model_data" WHERE name LIKE 'model_%' ORDER by module, name; -- all/most are 'ir.model' records
SELECT * FROM "ir_model_data" WHERE name LIKE 'field_%' ORDER BY module, name; -- all/most are 'ir.model.fields' records

Records for other resources may follow some convention or simply not:

SELECT * FROM "ir_model_data" WHERE name LIKE 'view_%' ORDER by module, name; -- all/most are 'ir.ui.view' records
SELECT * FROM "ir_model_data" WHERE model LIKE 'ir.ui.view' AND name NOT LIKE 'view_%' ORDER by module, name; -- 'ir.ui.view' records with unconventional names

I hope this helps you to clarify your doubts.

Regards,
Marvin

21
Awatar
Odrzuć
Dhinesh

+1 for prompt answer...

Darrel
Autor

Thanks a lot for the thorough answer Marvin. That's a lot of detailed info about Odoo I would have had a devil of a time digging up. I upvoted, and would set your answer to accepted, but the system won't let me.

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ść
server action for paid
server_actions
Awatar
Awatar
2
sie 24
3413
When button is clicked, the form will proceed to next stage and execute codes
server_actions
Awatar
0
sty 25
3418
Update provider order in purchase tab on product details Rozwiązane
server_actions
Awatar
Awatar
Awatar
2
cze 23
3052
Need Help Identifying Server Actions and Job Numbers
server_actions
Awatar
0
maj 23
3829
How to create a sever action on website ?
server_actions
Awatar
Awatar
1
cze 16
7418
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 Svenska ภาษาไทย 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