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

Issue with pass value from mode B into one2many field using dictionary of model A? (Odoo 13)

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
treeviewdictionaryone2many_listOdoo13one2manyfield
3 Odpowiedzi
4991 Widoki
Awatar
Leon

Hello,

I'm trying to pass values and show the records from the form view of model_b.py into one2many field notebook in the form view of model_a.py by wizard.


model_b.py  like this:

def accept(self):

        lstd = {

            'name': self.name.id,

            'thamchieu': self.id,

            'thoigian': self.thoigian,

            'bhxh': self.bhxh,

            'bhtn': self.bhtn,

            'bhxh_mucdongnld': self.bhxh_mucdongnld,

            'bhxh_mucdongcty': self.bhxh_mucdongcty,

            'bhtn_mucdongnld': self.bhtn_mucdongnld,

            'bhtn_mucdongcty': self.bhtn_mucdongcty,

            'bhyt_mucdongnld': self.bhyt_mucdongnld,

            'bhyt_mucdongcty': self.bhyt_mucdongcty

        }

        ls_dc = self.env['model.a']

        ls_dc = ls_dc.write({'lstd_baohiem':[(0,0,{lstd})]})


XML of one2many tree view in the form view of an user's model_a.py like this:

<notebook>

                            <page name="bao_hiem_lich_su" string="Lịch Sử Thay Đổi">

                                <field name="lstd_baohiem">

                                    <tree>

                                        <field name="thoigian"/>

                                        <field name="bhxh" string="M.Đ BHXH"/>

                                        <field name="bhtn" string="M.Đ BHTN"/>

                                        <field name="bhxh_mucdongnld"/>

                                        <field name="bhxh_mucdongcty"/>

                                        <field name="bhyt_mucdongnld"/>

                                        <field name="bhyt_mucdongcty"/>

                                        <field name="bhtn_mucdongnld"/>

                                        <field name="bhtn_mucdongcty"/>

                                        <field name="loai"/>

                                        <field name="thamchieu"/>

                                    </tree>

                                </field>

</page>

</notebook>


After clicking the button 'Accept'. I got the issue like that:

Odoo Server Error
Traceback (most recent call last):
  File "/home/odoo/src/odoo/odoo/http.py", line 624, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/home/odoo/src/odoo/odoo/http.py", line 310, in _handle_exception
    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
  File "/home/odoo/src/odoo/odoo/tools/pycompat.py", line 14, in reraise
    raise value
  File "/home/odoo/src/odoo/odoo/http.py", line 669, in dispatch
    result = self._call_function(**self.params)
  File "/home/odoo/src/odoo/odoo/http.py", line 350, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/home/odoo/src/odoo/odoo/service/model.py", line 94, in wrapper
    return f(dbname, *args, **kwargs)
  File "/home/odoo/src/odoo/odoo/http.py", line 339, in checked_call
    result = self.endpoint(*a, **kw)
  File "/home/odoo/src/odoo/odoo/http.py", line 915, in __call__
    return self.method(*args, **kw)
  File "/home/odoo/src/odoo/odoo/http.py", line 515, in response_wrap
    response = f(*args, **kw)
  File "/home/odoo/src/odoo/addons/web/controllers/main.py", line 1331, in call_button
    action = self._call_kw(model, method, args, kwargs)
  File "/home/odoo/src/odoo/addons/web/controllers/main.py", line 1319, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/home/odoo/src/odoo/odoo/api.py", line 387, in call_kw
    result = _call_kw_multi(method, model, args, kwargs)
  File "/home/odoo/src/odoo/odoo/api.py", line 374, in _call_kw_multi
    result = method(recs, *args, **kwargs)
  File "/home/odoo/src/odoo/addons/baohiem/models/dieu_chinh.py", line 128, in chapthuan
    ls_dc = ls_dc.write({'lstd_baohiem':[(0,0,{lstd})]})
TypeError: unhashable type: 'dict'

What am I doing wrong?

Please help!

Thank you!

0
Awatar
Odrzuć
Awatar
Jaga
Najlepsza odpowiedź


(0, 0, { values }) link to a new record that needs to be created with the given values dictionary (1, ID, { values }) update the linked record with id = ID (write *values* on it) (2, ID) remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well) (3, ID) cut the link to the linked record with id = ID (delete the relationship between the two objects but does not delete the target object itself) (4, ID) link to existing record with id = ID (adds a relationship) (5) unlink all (like using (3,ID) for all linked records) (6, 0, [IDs]) replace the list of linked IDs (like using (5) then (4,ID) for each ID in the list of IDs)

Check the above format,Confirm the error comes in some extra brackets or wrong rules you defined.

Example :

check the link

https://www.odoo.com/forum/help-1/not-able-to-write-datas-in-res-partner-res-partner-category-rel-table-182270

0
Awatar
Odrzuć
Awatar
Leon
Autor Najlepsza odpowiedź

Hello Mohamed,

Yes, I connect with model_c.py by creating a one2many field ('lstd_baohiem'), cause I want to put the tree view of model_c.py in the form view of a user of model_a.py. 

But model_c.py and model_b.py have connected by the relationship with one2many (model_b.py) and many2one (model_c.py). And I have done to pass all the value from model_b.py to the tree view of model_c.py via the KEY field of model_b.py:

reference = fields.Char('Reference')

Back to the model_a.py. I do not know how to create a many2one field for model_c.py to connect with one2many of model_a.py. 

Because the KEY field is 'reference' in model_b.py. That's the KEY field for 3 models not 2.

So that why I'm trying to copy or pass all values of the model_b.py by using dictionary like that. But still no sucess.

0
Awatar
Odrzuć
Awatar
Mohammed Zubair
Najlepsza odpowiedź

You can prepare values same like above and add model_b 'id' in Many2one field too.

Write: model_b.create(values) method if you have already model_a record is created.

After that you can see the newly created record gets added in One2many field.

0
Awatar
Odrzuć
Leon
Autor

Hi Mohammed. Cause I created one2many field: lstd_baohiem from... model C not model B. So you mean that I must have created a relation one2many from model.b.py and many2one from model.a.py!?

Mohammed Zubair

Let you have Model_a, Model_b and Model_c. Now you have relation between Model_a and Model_b as One2many and Many2one respectively. According to your above code, I can understand that you have field 'lstd_baohiem' in Model_a. That means, relation of One2many with Model_c and Model_a as Many2one, right?

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ść
key = 'default_' + name TypeError: must be str, not int (Odoo 13)
treeview many2one one2many one2many_list Odoo13
Awatar
0
lut 21
4553
How to pass values and create the records for field name according to the selection in one2many tree view? (Odoo 13)
many2one one2many_list Odoo13
Awatar
Awatar
1
kwi 25
4667
​OdooV13 : Hierarchical Tree view in Odoo 13?​
treeview hierarchy Odoo13
Awatar
Awatar
1
mar 22
6960
Raise warning when there is no select record via "Add a line" in one2many tree view!? (Odoo 13) Rozwiązane
one2many warning one2many_list Odoo13
Awatar
Awatar
Awatar
3
mar 21
6129
Is it possible to display data in a list view of a one2many field grouped by a field in Odoo 13 Rozwiązane
treeview one2many one2many_list odoo13
Awatar
Awatar
1
wrz 20
8804
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