Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Food & Hospitality
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Guest House
    • Distributor nápojů
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Trades
    • Údržbář
    • IT hardware a podpora
    • Solar Energy Systems
    • Výrobce obuvi
    • Úklidové služby
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Browse all Industries
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Services for Partners
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

Filter field domain one2many to many2one

Odebírat

Get notified when there's activity on this post

This question has been flagged
pythonpython2.7odooodoo10
1 Odpovědět
10280 Zobrazení
Avatar
Fazryan Fareka Riznendi

Hiiii...

I have a one2many field which contains 3 fields with 2 different values, for example. Here let's say the Zone is a one2many field.

Query;

Zone A = Car = 3000, Bike = 2000.
Zone B = Car = 2500, Bike = 1500.
Zone C = Car = 2000, Bike = 1000.

and I have many2one fields for the chosen field later (Ex. Car and Bike)

and rate_fields as trigger fields for calculations(a place to store value later)

the point is I want to select the "A" zone, then I select "Car" in many2one fields

the output at the rate field is 3000,

and if I select zone "B" then select "Bike" the output at the rate field is 1500

if written with code, then the implementation uses filter by domain with domain syntax Multiple Conditions.

Can anyone help me to make an example code?

maybe this is a reference but I can't make the appropriate code

Multiple Conditions

In Programming

if a = 5 or (b != 10 and c = 12)

In Open ERP domain filter

['|',('a','=',5),('&',('b','!=',10),('c','=',12))]

https://stackoverflow.com/a/19070664/9228786

Thank you in advance!! :D

0
Avatar
Zrušit
Avatar
La Jayuhni Yarsyah
Nejlepší odpověď

Is Your structure like this:

ZOne Table

Zone
A
B
C

Vehicle Table

Vehicle Name
Car
Bike


Rates Table

Zone ID(m2o)Vehiche Type ID (M2o)Rates(monetary/float)
A
Car
3000
A
Bike
2000
B
Car
2500
B
Bike
1500
C
Car
2000
C
Bike
1000

(Constrains between vehicle and zone), no same vehicle on same zone,



Your Transaction Table

zone_id (M2o)Vehicle ID (M2o)Rates(monetary/float)
A
Car
3000                
A
Bike
1500


If the structure that i wrote was right, then you just only set a onchange action on vehicle_id and zone_id in your transaction

@api.onchange('zone_id','vehicle_id')
def onchange_get_rates(self):
    if self.zone_id.id and self.vehicle_id.id:
        # calculate here
        # find in rates table
        rates = self.env['rates.table'].search([('zone_id','=',zone), ('vehicle_type_id','=',vehicle_type_id)])
        self.rates = rates.rates


But..! if "rates table" doesn't had any constrains between vehicle and zone,,
i mean than maybe in same zone has many rates for 1 same vehicle (example: [id:1] Zone A - Car -Rates = 3000, Zone A, [id:2] Zone A - Car - Rates = 3500)
so let the user select the rates based on zone and vehicle type, you must use onchange too,, where change modify fields domain, but in this case rates field was many2one

Ex:

Your Transaction Table

zone_id (M2o)Vehicle ID (M2o)Rate ID (m2o)
A
Car
1
A
Bike
2



so return domain change in onchange method

return {
    'domain':{
        'field_name':[(domain,'=',value)]
    }
}

3
Avatar
Zrušit
Fazryan Fareka Riznendi
Autor

I will try sir..

Big Thanks for response (Terimakasih banyak) :D

Fazryan Fareka Riznendi
Autor

i get error code ;

File "/home/fazryan/odoo/odoo/modules/registry.py", line 170, in __getitem__

return self.models[model_name]

KeyError: 'rates.table'

and this code that I implemented;

@api.onchange('parking_zone_rate_id','vehicle_typee_id')

def onchange_get_rates(self):

if self.parking_zone_rate_id and self.vehicle_typee_id:

# calculate here

# find in rates table

rates = self.env['rates.table'].search([('parking_zone_rate_id','=','name'), ('name','=','name')])

self.rates = rates.rates

please guide me, what should I do?

La Jayuhni Yarsyah

Usually in python, if that error showed up it caused by you try to call an attribute that not defined in object

And as you need to know that, not all that syntax that i wrote before was correct because i never test the code,, it just only to show you to try the flow/concept,,

It very depends on your model structure

So please understand the concept/sructure and flow,,, not to copy the code that i wrote before

I suggest you to explain your model structure more detail..

In that error message that class model "'rates.table" doesn't not defined...

Regards,

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
[SOLVED] How to Hide or Delete Trash Icon in One2many field Vyřešeno
python python2.7 odoo odoo10
Avatar
Avatar
2
srp 25
12840
Filter value 2 field of Many2one
python python2.7 odoo odoo10
Avatar
Avatar
Avatar
5
zář 20
6914
[Solved] Inherit fields to existing tables Vyřešeno
python python2.7 odoo odoo10
Avatar
Avatar
Avatar
4
led 19
10238
How to calculate the value of results in one2many field
python python2.7 odoo odoo10
Avatar
Avatar
1
led 19
7095
Generate XLSX(Excel) report in odoo 10 from custom module?
python python2.7 odoo odoo10
Avatar
Avatar
Avatar
2
čvc 18
15293
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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