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
    • Discuss
    • Kecerdasan Buatan
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • 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
    • Manajemen Properti
    • 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
    • Konsultasi
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan
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 to add a Javascript function to object through inheritance

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
javascriptinheritancemenuitemwebmodule
1 Balas
13573 Tampilan
Avatar
Eric

How can I create a custom javascript file that adds a new property and function to an inherited object, so that my custom menu item will open a new website?

So far, I created a custom web module that inherits from the original web module in Openerp 7.  

I added a new menu item in the User Menu by extending from the UserMenu template in the base.xml file.

Here is my custom xml code that adds a new menu item to the User Menu template.

(custom xml file.  This new menu item does appear in the User Menu )

<templates>

    <t t-extend="UserMenu">

        <t t-jquery="ul" t-operation="append">

           <li><a href="#" data-menu="website">Website Menu Item</a></li>

        </t>

    </t>

</templates>


base.xml (original)

<t t-name="UserMenu">

    <span class="oe_user_menu oe_topbar_item oe_dropdown_toggle oe_dropdown_arrow">

        <img class="oe_topbar_avatar" t-att-data-default-src="_s + '/web/static/src/img/user_menu_avatar.png'"/>

        <span class="oe_topbar_name"/>

        <ul class="oe_dropdown_menu">

            <li><a href="#" data-menu="settings">Preferences</a></li>

            <li><a href="#" data-menu="account">My OpenERP.com account</a></li>

            <li><a href="#" data-menu="about">About OpenERP</a></li>

            <li><a href="#" data-menu="help">Help</a></li>

            <li><a href="#" data-menu="logout">Log out</a></li>

        </ul>

    </span>

</t>


What I want to do now is inherit the UserMenu object that is defined in the web module's chrome.js file, into my custom javascript file.   Then I want to add a property to the UserMenu object so that a new website is opened when the menu item is clicked

Here is what I have so far:

 

openerp.web_custom = function(instance){

     // Add the on_menu_website property to the UserMenu object

     instance.web.UserMenu.on_menu_website = function() {

         //open the website  ...  its not working though

         window.open('http://www.website.com', '_blank');

     }

}


Here is the original js file code:

instance.web.UserMenu = instance.web.Widget.extend({

    template: "UserMenu",

    init: function(parent) {

       ... some code here ...

    },

    start: function() {

        ... some code here ...

    },

    do_update: function () {

        ... some code here ...

    },

    on_menu_help: function() {

        ... some code here ...

    },

    on_menu_logout: function() {

        ... some code here ...

    },

    on_menu_settings: function() {

        ... some code here ...

    },

    on_menu_account: function() {

        ... some code here ...

    },

    on_menu_about: function() {

        ... some code here ...

    },

});


One thing to note, if I add my new code the the original web module files (base.xml, chrome.js) then it works fine.  But I want to be able to create a custom web module so that I can add new functionality without modifying the original web module.  So my question is, how can I create a custom javascript file that adds a new property and function so that my menu item will open the new website?  Thank you for your help

0
Avatar
Buang
Avatar
Eric
Penulis Jawaban Terbai

I changed my custom javascript file to this. Then it worked


openerp.web_custom = function(instance){

     instance.web.UserMenu.include({

          on_menu_website: function () {

               window.open('http://www.website.com', '_blank');

          },

     });

}

2
Avatar
Buang
SHIV SHANKAR

Saved my day!! Thanks :)

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
Change onclick kanban project view (JS file)
javascript inheritance
Avatar
Avatar
1
Mar 22
8602
How to create custom menu which has default menu items customer , products and customer invoice ?
inheritance menuitem
Avatar
Avatar
Avatar
2
Des 21
10883
Inheriting NumberBuffercof pos to add 1000; 5000;10000 in PaymentScreen Diselesaikan
javascript pos inheritance
Avatar
Avatar
Avatar
2
Jul 24
4140
override method in javascript class class in odoo 16 Diselesaikan
javascript inheritance odoo16
Avatar
Avatar
Avatar
3
Mei 24
5250
Trouble Importing JavaScript Between Custom Odoo Modules
javascript inheritance js
Avatar
0
Mei 24
4854
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
  • Karir
  • 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 Svenska ภาษาไทย 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