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 i Populate Many2One field on change of another field on v8?

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
many2onemany2manyonchangeodooV8
2 Odpowiedzi
8898 Widoki
Awatar
Abdallah Sahabn

if i have model project that have one or more from model unit , then i have another model that i want to select project then on change the project want to populate the units according to project selection 

example 

have project 1 have units 1,2 ,3 

project 2 have units 1,4,5 


when select project want to populate the units 1,2,3 if changed to project 2 populate  the units 1,4,5

i have written my own code to get the list of related units, just want to know how i can set this list to the units 


here is the code


class rsproject(models.Model):
    _name = 'rs.project'
    units = fields.One2many('rs.unit','name',string ='Units', ondelete='cascade')

class rs_unit(models.Model):
    _name="rs.unit"
project = fields.Many2one('rs.project', ondelete='cascade', string="Project", required=True)

class rsreservation(models.Model):
    _name = 'rs.reservation'
    project = fields.Many2one('rs.project', ondelete='cascade', string="Project", required=True)
    unit = fields.Many2one('rs.unit', ondeletel='cascade', string="Unit Number", required=True)

    @api.one
    @api.onchange('project')
    def on_change_project(self):
	    units_obj = self.pool.get('rs.unit') 
		project_id =  self.project.id
        #get units list according to selected project 		
		unit_list = units_obj.search(self._cr,self._uid,[('id','=',project_id)])
		# what is the correct syntax to set the unit field with unit_list
0
Awatar
Odrzuć
Baiju KS

please include view file...

Awatar
Jaakko Komulainen
Najlepsza odpowiedź

Hi, you can populate your many2one field like this (assuming "related_units" is the name of the m2o field):


return = { 
    'value': { 'related_units': [(6,0,list_of_related_units)] }
}

Edit: 

You should check this: https://www.odoo.com/forum/how-to/developers-13/what-should-onchange-methods-do-and-return-57760

0
Awatar
Odrzuć
Abdallah Sahabn
Autor

please see the updated question with the code, and let me know where i can put your suggestion

Jaakko Komulainen

updated original answer

Abdallah Sahabn
Autor

i returned the domain but it is not working also return {'domain': {'unit':[('id','=',unit_list)]} }

Awatar
Baiju KS
Najlepsza odpowiedź

Hi,

You can use domain filter for your need....

In ODOO domain filter, it will be written as:

syntax : Each tuple in the domain has three fields -> (‘field_name’, ‘operator’, value)

field_name : a valid name of field of the object model or in the database table

operator : valid operators are =, !=, >, >=, <, <=, like, ilike, in, not in, child_of, parent_left, parent_right (openerp/osv/expression.py)

value : a valid value to compare with the values of field_name, depending on its type.


You can use this;

domain = [(‘field1′,’=’,field2)] 

you can use filter for your unit with project.


Hope this helps............



0
Awatar
Odrzuć
Abdallah Sahabn
Autor

please see the updated question with the code, and let me know where i can put your suggestion

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 the previous value of field in onchange odoo 8? Rozwiązane
many2one onchange last_modified odooV8
Awatar
Awatar
Awatar
Awatar
Awatar
6
cze 21
26549
Domain filtering many2one field dependent onchange from other field
many2one many2many onchange context domain_filter
Awatar
Awatar
1
kwi 20
8151
how to get(show) many2many records by selecting the Many2one? in odoo10
many2one customers many2many onchange odoo10
Awatar
Awatar
2
sty 20
4847
Load invoices of partner,parent and all childs
many2many onchange
Awatar
0
lut 19
4247
when i select the category in the sale list the regarding product must shown in the product id in the bill list by onchange
many2one onchange
Awatar
0
gru 18
13
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