Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

Filter value 2 field of Many2one

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
pythonpython2.7odooodoo10
5 Răspunsuri
6991 Vizualizări
Imagine profil
Fazryan Fareka Riznendi

Hello World :D

please help, I want to filter values ​​from fields that are in many2one.
I have tried various ways, but still have difficulties in understanding.

so this my code;

zona_parkir=fields.Char('Zona Parkir', related='location_id.zone_id.name', readonly='True')
location_id=fields.Many2one('parking_location', string='Lokasi', required='True')
 class ParkingLocation(models.Model): #parking_location
_name='parking_location'
_rec_name='name'

name=fields.Char('Lokasi')
zone_id=fields.Many2one('parking_zone', string='Zona')
class ParkingZone(models.Model):
_name='parking_zone' #parking zone
_rec_name='name'

name=fields.Char('Zona Parkir')    billing=fields.Float('Tarif')
information=fields.Text('Keterangan')
 parking_log_ids=fields.One2many('parking_log','parking_log_id',string='Log Parkir')class ParkingLog(models.Model):
_name='parking_log'
_rec_name='vehicle_id'
vehicle_id=fields.Many2one('vehicle',string='Nomor Kendaraan')
vehicle_type_id=fields.Char(string='Jenis Kendaraan', related='vehicle_id.vehicle_type.name', readonly='True')
rate_id=fields.Float('Tarif / Jam', related='vehicle_id.vehicle_type.billing')
user_id=fields.Many2one('res.users',string='Juru Parkir', default=lambda self: self.env.user, readonly='true')
parking_log_id=fields.Many2one('parking_session', string='Sesi Parkir', readonly='True')

    total_rate=fields.Float(string='Total Biaya Parkir',states={'in' : [('readonly', 'False')], 'paid' : [('readonly', 'False')]}, store='True', readonly='True', compute='action_close', track_visibility='onchange')
parking_point_id=fields.Many2one('parking_point',string='Titik Parkir')
parking_location_id=fields.Char('Lokasi Parkir', related='parking_log_id.location_id.name',readonly='True')
parking_zone_rate_id=fields.Char('Zona Parkir', related='parking_log_id.zona_parkir',readonly='True')
parking_hours=fields.Float('Lama Parkir', store='True', readonly='True', compute='action_close', track_visibility='onchange')


class Vehicle(models.Model): _name='vehicle' _rec_name='vehicle_number' vehicle_type=fields.Many2one('vehicle_type',string='Jenis Kendaraan',ondelete='cascade')
    vehicle_number=fields.Char(string='Nomor Kendaraan'
class VehicleType(models.Model): _name='vehicle_type'

    name=fields.Char('Jenis Kendaraan')
    billing=fields.Float('Tarif')

so the point is,  when I select ('location_id')

suppose I make 3 zones in that field,
zone X = B = 2 and C = 3
zone Y = B = 1.5 and C = 2.5
zone Z = B = 1 and C = 2

then the value I previously inputted has been recorded in the "billing" field and when I "add item" in the o2m field, the value in it is the filter result from the zone of one of the zones I selected

What do I think I should do?

maybe there is my code that is not supposed to exist / is not suitable.
also ask for advice :D


I will appreciate all forms of answers, thank you very much :-D

0
Imagine profil
Abandonează
Sehrish

try this: https://learnopenerp.blogspot.com/2020/09/domain-filter-many2one-field-odoo13.html

Imagine profil
Simplify-ERP® Developers
Cel mai bun răspuns

Hello, i understand what you need and here i am going to post a code block that i used to filter the products shown to a user on a sale order:

    def _get_products(self):
        ids = []
        res = {}
        for i in self.sale_order_id.order_line:
            ids.append(i.product_id.id)
        res.update({
                'domain': {
                    'call_product_id': [('id', 'in', ids)],

                }
            })

        return res
So here in the code block, only the products that were added on the original sale order, would get shown on my many2one field with name call_product_id to product.template for another model.

i hope that you can use this for your own good, remember to change the model and the field name too, mine is called call_product_id = fields.Many2one('product.template',string = 'Product')

Riste Kabranov

odoo developer at simplify-erp.com

0
Imagine profil
Abandonează
Fazryan Fareka Riznendi
Autor

thank you for the response,

my code now ;

def _get_products(self):

ids = []

res = {}

for i in self.parking_zone_rate.name:

ids.append(i.rate_id.id)

res.update({

'domain': {

'parking_zone_rate_id': [('id', 'in', ids)],

}

})

return res

but still have difficulties in understanding :(

if i use domain like this code, can you help how?

Multiple Condition

Simple condition in programming:

if field1 = 5 or (field2 ! = 10 and field3 = 12)

In OpenERP domain filter, it will be written as:

domain = ['|',('field1','=',5),('&',('field2','!=',10),('field3','=','12'))]

thanks before :D

Imagine profil
Nikunj Dhameliya
Cel mai bun răspuns

Hi,

You can filter records by using domain in XML.

If this is not worked then try to send many2one I'd in context and use name_search method to filter record

0
Imagine profil
Abandonează
Fazryan Fareka Riznendi
Autor

thankyou for the response,

can you tell me how?

or what code should I make?

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

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

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
[SOLVED] How to Hide or Delete Trash Icon in One2many field Rezolvat
python python2.7 odoo odoo10
Imagine profil
Imagine profil
2
aug. 25
12934
Filter field domain one2many to many2one Rezolvat
python python2.7 odoo odoo10
Imagine profil
Imagine profil
1
dec. 19
10355
[Solved] Inherit fields to existing tables Rezolvat
python python2.7 odoo odoo10
Imagine profil
Imagine profil
Imagine profil
4
ian. 19
10322
How to calculate the value of results in one2many field
python python2.7 odoo odoo10
Imagine profil
Imagine profil
1
ian. 19
7142
Generate XLSX(Excel) report in odoo 10 from custom module?
python python2.7 odoo odoo10
Imagine profil
Imagine profil
Imagine profil
2
iul. 18
15359
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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