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

[Odoo 12] How to perform a search on a One2many field through a wizard?

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
wizardone2manysearch12.0
2 Replies
15996 Tampilan
Avatar
Willem Datema

Hello all,

I am trying to perform a filter/search through a wizard for a One2manyfield. The One2manyfield connects to the model stock.picking. I created a TransientModel in which a user can pick a Sale Order and the wizard should return a form with a filtered one2many field. The form will then only show the pickings which have the Sale Order that the user selected as Origin. The TransientModel looks like this:

class SearchPacking(models.TransientModel):
    _name = 'search.packing'
_description = 'Search a packing'

sale_order_id = fields.Many2one('sale.order',string="Sale Order")

def search_filtered_packing(self):
return {
'type':'ir.actions.act_window',
'view_type':'form',
'view_mode':'form',
'src_model':'search.packing',
'res_model':'pickpack.packview',
'target':'new',
'res_id':self.env.context.get('active_id'),
'domain':[('origin','=',self.sale_order_id)]
}


The model pickpack.packview is a model that shows all the pickings with picking type "Pack" in a batch. It has a one2many field that looks like this:

class PackView(models.Model):
    // OTHER DEFINITIONS ​   ​    ​   ​     ​   ​    ​   ​
    pickings = fields.One2many('stock.picking','packviews',string='Operations to pack',readonly=False,store=True, compute='_compute_operations_to_pack')
@api.one
@api.depends('batch_id')
def _compute_operations_to_pack(self):
self.ensure_one()
res = self.env['stock.picking']
for picking in res.search([('batch_id','=',self.batch_id.id),('picking_type_id.name','=','Pack')]):
res += picking
self.pickings = res

What happens now if I click the button in the wizard that calls search_filtered_packing (after selecting a Sales Order) is that I just get the same model back, without any filters. 
The One2Many field is searchable on Sales Order in the tree view. Can anyone see what is going wrong here?


Thanks in advance.

0
Avatar
Buang
Avatar
Ryan Tran
Jawaban Terbai

Hi,

There are some problems in your solution:

  • If you really mean to compute the One2many field, you should not define it with the inverse_name. By doing this, there are no real connection between these 2 models, and you cannot store this o2m field. If the relation already exist between 2 model with the m2o relation defined in the corresponding model, then you can only apply domain to decide what to be shown.

  • You cannot domain a form view, but you can domain a field shown as tree in the form view, if you return correct value to domain that field in particular.

Then the solution now is depends on what you want to achieve:

  • You can add a sale_order_origin to stock.picking form view to apply domain dynamically to the related one2many field, with an onchange function.

  • If you want to use the wizard, then from that wizard, you select the reference Sale Order, then assign the result recordset to an m2m field on the wizard, and then finally write those m2m ids to the o2m field in stock.picking.

I think you would want to domain what to be picked base on the Sale Order (delivery operation) rather than automatically creating o2m record from the wizard. Then returning domain for a selected field using onchange function is your best friend. Try :

return {'domain':{'picking_ids': [('origin', '=', self.sale_order_id.name)]}}
1
Avatar
Buang
Avatar
faOtools
Jawaban Terbai

You return a form view and, moreover, you return res_id in your method. So, you say to Odoo - 'show me a form of this object in a new window'. The param domain is applied to tree, kanban, calendar views: so to any where there are a few items.

A few other comments:

  • How might origin (char) be equal to sale_order_id (recordset)?

  • What for do you need 'src_model'?

Thus, you should re-develop your action to return, for example a list. Something like:

@api.multi
def search_filtered_packing(self):
self.ensure_one()
return {
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'pickpack.packview',
'type': 'ir.actions.act_window',
'domain':[('origin', '=', self.sale_order_id.name)],
}
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 open wizard from "Add a line" link of One2many field?
wizard one2many
Avatar
Avatar
1
Jun 24
443
Smart search of phone numbers. Diselesaikan
search 12.0
Avatar
Avatar
2
Des 20
5670
Read values from one2many relation
one2many search
Avatar
Avatar
1
Nov 18
3538
One2many through wizard, (without errors, but no add to the record)
wizard one2many
Avatar
Avatar
1
Feb 16
5754
One2many field on wizard opens by itself
wizard one2many print
Avatar
Avatar
1
Sep 23
2874
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