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

Access an object field from another object

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
newmodule
1 Odpowiedz
4463 Widoki
Awatar
Pau Ubach

I have the following situation: 

An object A has a view with a field many2one of the object B, and B has a many2one of the object C.

A also has a related field A1 which displays a field (C1) in the object C, but we can select its value directly in A view.

I can select an existing B or create a new one. The same with C.

When I select to create new B and C I get the form view for the new object C. 

 

How can I set the value in C1 to be equal to A1?

 

I'm trying with:

def default_get(self, cr, uid, fields, context=None):
            _logger.info('Inside bdd_project.default_get')
            if context is None:
                context = {}
            res = super(bdd_project, self).default_get(cr, uid, fields, context=context)
            pl_obj = self.pool.get('bdd.pricelist')
            pl = pl_obj.browse(cr, uid, context.get('cus_id'), context=context)
            if 'cus_id' in fields:
                _logger.info('Inside if cus_id: value %s', pl.cus_id)
                res.update({'cus_id': pl.cus_id})
            return res

 

where bdd_project would represent the object C and bdd_pricelist would be A.

pl.cus_id is returning None.

0
Awatar
Odrzuć
Awatar
Ivan
Najlepsza odpowiedź

Pau, the notion of having a related field means that you SHOULD NOT edit the value directly.  If you want to sync C1 with the value of A1 which is selected by User, then you should not define A1 as a related field, but define it as a normal field.

Then you on write (or create) of A, you can update the related C1 field value based on the value set by user.

0
Awatar
Odrzuć
Pau Ubach
Autor

The normal flow should be from C to A, I mean that C1 should be already defined when the view A is opened, and that's why it's a related field. But there's a rare scenario where an user could want start defining from A to C, and that's why I need to implement it this way.

Ivan

Pau, even if it is a rare chance, you still need to implement the synchronization, i.e. change A1 if C1 is updated and C1 if A1 is updated. You still can default A1 to display whatever value C1 is holding. Another approach that you may want to consider is to display B in A's form and C in B's form, hence user can change C1 from C's form instead of changing it from A's form. More longwinded for user, I understand.

Pau Ubach
Autor

John, what do you mean by implement the synchronization? Do you have a link to any document explaining how to do it? The request is to display C1 in A, and then filter B by this value.

Ivan

Pau, your first problem description is that user need to be able to change A1 and then C1 need to be change to be equal to A1. Does this still a requirement? If so, my answer stands. Synchronization is basically changing C1 when A1 is changed by user and A1 if C1 is selected by user. You need to inherit method write of both class A and C. For, say class A, you need to detect if there is any change in A1, and then change the related C1 value to be the same as A1, vv. If your first problem description is not correct, then I would suggest that you restate what you really need so the answer can be crafted more accurately.

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 debug view XML when openerp doesn't say anything about it? Rozwiązane
newmodule
Awatar
Awatar
Awatar
2
mar 15
8681
Adding new modules in OpenERP
newmodule
Awatar
Awatar
2
mar 15
4391
Integrity Error with calendar.event module
newmodule
Awatar
0
mar 15
4297
Display a day in a schedule for a period
newmodule
Awatar
0
mar 15
4697
MRP module installed, but not available in the home screen Rozwiązane
mrp newmodule
Awatar
Awatar
1
cze 16
4623
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