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

Override Many2ManyListView under web.form_relational !!

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
widgetjs
1 Balas
4861 Tampilan
Avatar
Pawan

Hello guys,

I have a requirement in which i have to override Many2ManyListView class from "web/static/src/js/views/form_relational_widget.js" under "web.form_relational"

But as web.form_relational does not return 'Many2ManyListView'(so i can't use '.' notation to access) nor its adding it in form_registery(to access it from registery), i am not getting the correct  way to override 'Many2ManyListView'


Any help would be appreciated...


Thanks!

0
Avatar
Buang
Avatar
Axel Mendoza
Jawaban Terbai

*** update that works directly without more investigation, i will left the original answer as a reference ***

Odoo class/widget functions extend and include have something in common. That is that both functions apply the received javascript object properties to the class/widget. The difference between those Odoo class/widget functions is that the extend function is used to get a copy of the Odoo class/widget with the modifications without been modify the original class/widget by returning the modifications in a new class/widget. The include function will do the modifications in place to the class/widget without returning anything new.

To reach the class/widget Many2ManyListView for been able to use extend or include functions the best way is using the following code:

var core = require('web.core');

var FieldMany2Many = core.form_widget_registry.get('many2many')

var extention_not_done = false;

FieldMany2Many.include({

init: function() {

this._super.apply(this, arguments);

//if(extention_not_done){

     if(!extention_not_done){

var Many2ManyListView = this.x2many_views.list;

// use include to modify the original

Many2ManyListView.include({

});

// or use extend to create a copy with the modifications

var Many2ManyListView_New = Many2ManyListView.extend({

});

extention_not_done = true;

}

}

});

That technique consist of using an include extension to the FieldMany2Many init and call the original init function by calling the super so the class widget will be initialized and you could then access to the original Many2ManyListView class/widget. Just need a check due the init of the FieldMany2Many will be called by many times and we don't wanna applying the extension to the Many2ManyListView several times, we just need one.

*** original answer ***

Try it this way:

var core = require('web.core');

var FieldMany2Many = core.form_widget_registry.get('many2many')

var Many2ManyListView = new FieldMany2Many(args).x2many_views.list

/*** examples ***/

Many2ManyListView.include({

});

var Many2ManyListView_New = Many2ManyListView.extend({

});

With tha code you just need to investigate what need to be passed as args for the FieldMany2Many instantiation and you will be able to call the include or extend on the retrieved Many2ManyListView 

1
Avatar
Buang
Pawan
Penulis

Thanks a lot axel, frankly i was expecting an answer from you....

what i have done is returned Many2ManyListView also from form_relational(knowing that is not the correct way, but it worked somehow.)

anyway will try it soon and update u...

thanks

Pawan
Penulis

One more thing, can just explain a difference between this include n extend.. how it works programmaticaly ...

Axel Mendoza

sure, let me answer your question about the difference of include and extend with an answer update since I found a direct solution to the original problem that directly works

Axel Mendoza

check it now the previous answer updates

Pawan
Penulis

Thanks Axel, it worked very well, just a modification needed(inplace of "if(extention_not_done)", it should be "if(!extention_not_done)", which i have updated), rest everything is fine..

Thanks once again...

Axel Mendoza

please don't forget to accept and upvote the answer if it was helpful

Pawan
Penulis

And regarding extend and include i have noticed one more thing, when we use 'extend' it is not calling the overriding method as in above case for Many2ManyListView, i was trying to override do_activate_record by extending Many2ManyListView, but it is not calling overriding method(still going with the base method),

do you have any idea why is ti happening so...?

Axel Mendoza

read carefully what I wrote about that, extend will not modify the original class/widget, it will return a new class/widget with the modifications

Pawan
Penulis

oh.. ok , i missed, thanks once again...

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
Extending/Overriding public widgets.
widget js
Avatar
Avatar
1
Mei 23
8391
problem with bind a js widget and xml Template to add it in html dev
widget templates js
Avatar
Avatar
1
Jun 23
3776
Sign App won't display PDF while custom JS widget added to the SystrayMenu
widget js sign
Avatar
0
Jan 21
3471
Error: "Could not find client action MyWidget" in widget [Odoo 12.0alpha1+e]
widget js master
Avatar
Avatar
Avatar
2
Des 19
9240
How to Inheirt SectionAndNoteListRenderer function to include my custom code Diselesaikan
widget js render
Avatar
Avatar
1
Des 19
6432
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