Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Diskusi
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

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

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

How filter x2many?

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
filterdomainx2many
3 Replies
12909 Tampilan
Avatar
Vasiliy Birukov

Is it possible filter list of x2many records in form view?

For example:

1)Show only first 5 lines.

2)Show only records, that have fields according to some domain.

6
Avatar
Buang
Avatar
Andreas Brueckl
Jawaban Terbai

Regarding the change of the limit of one2many fields please refer to question https://accounts.openerp.com/forum/Help-1/question/6627/

Regarding the filter I had the same requirement for one of our modules and I have solved it with the following steps. Assume that you have the following one2many field which you want to filter:

'line_ids': fields.one2many('your.model', 'script_id', 'Lines'),
  1. Add a filter field to your model:

    'ir_filter_id': fields.many2one('ir.filters', 'Additional Filter', domain=[('model_id', '=', 'your.model')]),
    
  2. Add a one2many function field to your model:

    def _get_lines(self, cr, uid, ids, fields, args, context=None):
        line_obj = self.pool.get('your.model')
        res = {}
        for script in self.browse(cr, uid, ids):
            args = [('script_id', '=', script.id)]
            if script.ir_filter_id:
                args += eval(script.ir_filter_id.domain)
            line_ids = line_obj.search(cr, uid, args)
            res[script.id] = line_ids
        return res
    
    def _set_lines(self, cr, uid, id, name, value, inv_arg, context):
        line_obj = self.pool.get('your.model')
        for line in value:
            if line[0] == 1: # one2many Update
                line_id = line[1]
                line_obj.write(cr, uid, [line_id], line[2])
        return True
    
    'view_line_ids': fields.function(_get_lines, fnct_inv=_set_lines, string='Lines', relation="your.model", method=True, type="one2many"),
    
  3. Add the two fields to your form view

So you can filter your one2many field with any domain. You only have to be aware of the following points:

- The filter is stored in the DB and all users have the same filter - You have to save the form view so that the current filter becomes active

8
Avatar
Buang
priyankahdp

please help me for this issue..

http://help.openerp.com/question/8391/how-to-load-child-records-to-fields/

Timo Talvitie, Vizucom Oy

Big thanks for posting this, it worked nicely after adding also checks for line[0] being 0 or 2 (create or delete). I think there shouldn't have to be this much magic involved when wanting to filter a basic o2m field, though.

Avatar
Vasiliy Birukov
Penulis Jawaban Terbai

Thanks to Andreas Brueckl for idea with second functional 'view' field, example first case may be (filter first 5):

def _get_lines(self, cr, uid, ids, name, arg, context=None):
        line_obj = self.pool.get('your.model')
        res = {}
        number = 5
        for script in self.browse(cr, uid, ids, context=context):
            line_ids = line_obj.search(cr, uid,[('script_id', '=', script.id)], limit=number)
            res[script.id] = line_ids
        return res

'view_line_ids': fields.function(_get_lines, relation="your.model", method=True, type="one2many"),
5
Avatar
Buang
Avatar
Gabriel
Jawaban Terbai

Thanks to Andreas for this detailed answer, the fnct_inv definition saved me some time. I would suggest for others that might need it, you can add:

elif line[0] == 0: # one2many create
     self.create(cr, uid, line[2])

to the _set_lines function if you want to create new record.

0
Avatar
Buang
Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
Filter many2one field with functional field
filter domain
Avatar
Avatar
Avatar
5
Sep 20
13571
How to set default filter for an addon?
filter domain
Avatar
0
Mar 15
4742
Problem with column iteration in domain filter
filter domain
Avatar
1
Mar 15
6225
How to allow read parent tasks to followers
filter domain
Avatar
Avatar
Avatar
2
Mar 15
8409
How to use dynamic values in domain filter? Diselesaikan
filter domain code
Avatar
Avatar
Avatar
Avatar
Avatar
6
Mei 24
72046
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

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