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

onchange return domain for one2many product ID Field

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
domainone2manyonchange
7 Replies
19879 Tampilan
Avatar
Prakash

Using (Sale Order) onchange Function how to add return domain for (Sale Order Line) one2many table Product ID Field?..

In Default onchange domain return example available for same table and column.

Example: return {'domain': {'column_name': [('id', 'in', listids)]}}

But how to add domain in one2many table Field using onchange method ?..

Requirement:-  Sale Order based on Partner selection dynamic add domain in Sale Order Line Product Field.

Code:

  def onchange_partner_id(self, cr, uid, ids, part, context=None):
        res = super(sale_order, self).onchange_partner_id(cr, uid, ids, part, context=context)       
        res['value'].update({'order_line': []})
        if part:
            product_obj = self.pool.get('product.product')
            matching_cust_ids = product_obj.search(cr, uid, [('x_cust_name','=',part)])            
            res['value'].update({'custproduct_id': matching_cust_ids})   
            domain = {'domain':{'order_line.product_id': [('order_line.id', '=', matching_cust_ids)]}}    
            res['value']['order_line'].append(domain)             
        return res       

Issue: The above code return domain for one2many table product Field is not working.

0
Avatar
Buang
Alex Gallien

For more background, what we were trying to do earlier (https://www.odoo.com/forum/help-1/question/limiting-customers-to-specific-products-58972) is link a customer and a product using a field on many2one field on the product page - 'x_cust_name': fields.many2one('res.partner', 'Customer', store=True). Ideally the module would only display the products that have the 'x_cust_name" equal to the name of the customer on the Sales Order.

Alex Gallien

Prakash - Janeesh's solution below worked! I think we were seriously overthinking things. Thanks again for your help, I really appreciate it.

Avatar
Janeesh
Jawaban Terbai

If field_id is a many2one field to partner, then you can simply give domain in xml for product_id field. Domain should be domain="[('field', '=', parent.partner_id)]"

11
Avatar
Buang
Alex Gallien

Ah of course it is way simpler than we were trying to make it. This worked perfectly using 'edit form view' from dev mode, but I am having trouble figuring out how to declare the xpath in my module. I am adding an answer with my code - if you could take a look I would really appreciate it.

Alex Gallien

Actually, scratch that - I figured it out. Thanks for the help!!

Avatar
John Daniel
Jawaban Terbai

If field_id is a many2one field to partner, then you can simply give domain in xml for product_id field. Domain should be domain="[('field_id', '=', parent.partner_id)]"

3
Avatar
Buang
Avatar
Alex Gallien
Jawaban Terbai

Janeesh - here is my attempt to implement your solution in a module. The domain isn't showing up for me right now, and I think it is because of my xpath declaration. Could someone help me figure out how to declare this domain correctly? Thanks!

EDIT: For anyone wondering the solution here, I think it had to do with the fact that the 'field' tag I was looking for was embedded past another field tag. The xpath that ended up working for me was:

 <xpath expr="//field[@name='order_line']/tree/field[@name='product_id']"

which actually could be shortened to 

xpath expr="//tree/field[@name='product_id']"

Here is my original (not functional) code.

   

    <record id="view_quotation_tree" model="ir.ui.view">

        <field name="name">sale.order.form</field>

        <field name="model">sale.order</field>

        <field name="inherit_id" ref="sale.view_order_form"/>

        <field name="arch" type="xml">

           <xpath expr="//field[@name='product_id']" position="replace">

              <field name="product_id" context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'shop':parent.shop_id, 'uom':product_uom}" groups="base.group_user" on_change="product_id_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, product_uos_qty, product_uos, name, parent.partner_id, False, True, parent.date_order, False, parent.fiscal_position, False, context)" domain="[('x_cust_name', '=', parent.partner_id)]"/>

           </xpath>

        </field>

     </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
How to return domain on one2many field so that seleted values are not shown in next line
domain one2many onchange
Avatar
1
Apr 23
5930
How to update two levels o2m fileds relation
one2many onchange
Avatar
0
Sep 20
3710
How i can Apply onchange method on one2many field ?
domain onchange
Avatar
Avatar
1
Sep 19
5186
Several levels of One2many
one2many onchange
Avatar
0
Apr 16
3834
One2many onchange in ODOO Diselesaikan
one2many onchange
Avatar
Avatar
3
Mar 16
14880
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