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

[SEARCH] How to search in Odoo 16

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
many2oneone2manysearchid
3 Odpowiedzi
4909 Widoki
Awatar
BB

I have 2 model: contract, tenant.

I want to know tenant_id have in contract. 


Model Contract: 

class PmaContract(models.Model):    
​_name = "pma.contract"   
​_inherit = ["mail.thread", "mail.activity.mixin"]   
​_description = "Manage contract"
    ​state = fields.Selection([
​ ​("draft", "Draft"),           
​ ​("to_link", "To link"),
          ("active", "Active"),           
​ ​("expired", "Expired"),           
​ ​("liquidated", "Liquidated")],       
​ ​string="Status",       
​ ​copy=False, index=True, readonly=True, store=True)
    ​lessor = fields.Many2one("res.users",string="Party A (Lessor)",store=True,        required=True,    )
    apartment = fields.Many2one("pma.apartment", string="Apartment name", required=True)
    room = fields.Many2one("pma.apartment.room",string="Room name", domain="[('apartment', '=', apartment)]",        ondelete="restrict",        store=True,        required=True,    )    floor = fields.Many2one(related="room.floor")
    duration_from = fields.Date(string="From", store=True, required=True)    duration_to = fields.Date(string="To", store=True, required=True)
    lessee = fields.Many2one("pma.tenant", string="Representative", store=True, ondelete="restrict", required=True, domain="[('owner', '=', lessor)]",    )
​name = fields.Char(string="Contract ID", compute="_compute_name", store=True)   
​member = fields.Many2many("pma.tenant", store=True, string="Member",domain="[('owner', '=', lessor), ('id', '!=', lessee)]",)

Model Tenant: class PmaTenant(models.Model):   
​_inherit = "pma.tenant"
    ​ ​contract_id = fields.One2many("pma.contract", "lessee", string="Contract", copy=True)
I want to get Tenant(lessee) when contract have status = "active", "liquidated" and don't have in contract.

Please help me ....

0
Awatar
Odrzuć
Awatar
BB
Autor Najlepsza odpowiedź

I have 2 model: Contract & Room. 


In model room I have a selection field to set state for room. 


They are my model:


- Room:

	​
class PmaApartmentRoom(models.Model):    
​_inherit = "pma.apartment.room"
    contract = fields.One2many("pma.contract", "room", string="Contract")
    state = fields.Selection([
​ ​("available", "Available"),
​ ​("rented", "Rented")],
​ ​string="Status", copy=False,
​ ​index=True, readonly=True, store=True, tracking=True)
  class PmaContract(models.Model):   
​_name = "pma.contract"   
​_inherit = ["mail.thread", "mail.activity.mixin"]   
​_description = "Manage contract"
    state = fields.Selection([
​ ​("draft", "Draft"),           
​ ​("to_link", "To link"), 
        ​("active", "Active"),
        ("expired", "Expired"), 
        ("liquidated", "Liquidated")],       
​ ​string="Status", default="draft", copy=False,       
​ ​ index=True, readonly=True, store=True, tracking=True,)
   
​room = fields.Many2one("pma.apartment.room", string="Room name",        ​ ​domain="[('apartment', '=', apartment)]",        ​ ​ ​ ​ ​ ​ondelete="restrict", store=True, required=True, tracking=True)
State of contract = "active" => state of room = "rented".

State of contract in ["draft", "to_link", "expried", "liquidated"] => state of room = "available"


Please help me ....


0
Awatar
Odrzuć
Awatar
Cybrosys Techno Solutions Pvt.Ltd
Najlepsza odpowiedź

Hi,

Use Odoo's domain filter to limit your search results to tenants (lessees) with contracts with the status "active" or "liquidated" but no other statuses. These domain requirements can help you achieve this:

tenants_active_liquidated_contracts = self.env['pma.tenant'].search([
    ('contract_id.state', 'in', ['active', 'liquidated']),
    ('contract_id', '!=', False),
])

# You currently have a list of tenants with active or liquidated contracts.
for tenant in tenants_active_liquidated_contracts:
    print("Tenant Name:", tenant.name)  # Replace 'name' with the actual field you want to display


To find tenants who meet the required criteria, we use the search method on the pma.tenant model. We use a domain filter to check if the contract_id field (One2many) is not empty, meaning the tenant has contracts. The state of the contracts (contract_id.state) is also checked to see if it falls within the category of "active" or "liquidated" statuses. The tenants who have contracts with the stated statuses and who don't have contracts with other statuses will be listed for you. The tenant information can then be accessed by iterating through this recordset as needed


Hope it helps

0
Awatar
Odrzuć
Awatar
Savya Sachin
Najlepsza odpowiedź

Hi,

Try like this in order to get tenants which satisfy your condition mentioned above,

tenant_ids = self.env['pma.tenant'].search(['|',('contract_id.state', 'in', ['active', 'liquidated']),
('contract_id', '=',False)])

Thanks

0
Awatar
Odrzuć
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 do I put One2many after Many2one defined? - transient module states reset
many2one one2many
Awatar
1
mar 23
3115
Odoo Studio how to set a chain of multiple and related Many2one within a One2many lines
many2one one2many
Awatar
0
gru 22
3760
filter according to comodel's fields
many2one one2many
Awatar
0
cze 21
3472
Show self related record value in tree view for custom model Rozwiązane
date many2one one2many search self.env.search
Awatar
Awatar
1
gru 20
4392
How to display other fields of a onetomany relation ?
many2one one2many
Awatar
0
cze 20
6306
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