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

Show variant specific description on product site ecommerce

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
webclientdevelopmentportalecommerce
1 Balas
2197 Tampilan
Avatar
Kasper

I'm building an odoo18 module that would show unique product variant descriptions on the ecommerce site. The description must also update when user change the variant on the website (not necessarily reloading whole page).

And this is a step where I got stuck and would ask for help ;) 


here are important files for my configuration - this works just fine

model

class ProductProduct(models.Model):

    _inherit = 'product.product'

    website_description_variant = fields.Html(

        string="Website Description (Variant)",

        translate=True

    )


class ProductTemplate(models.Model):

    _inherit = 'product.template'


    def _get_combination_info(self, *args, **kwargs):

        res = super()._get_combination_info(*args, **kwargs)

        product_id = res.get('product_id')

        if product_id:

            product = self.env['product.product'].browse(product_id)

            res['website_description_variant'] = product.website_description_variant or ""

        return res

xml portal view:

<odoo>

    <data>

        <template id="website_product_variant_description_snippet" inherit_id="website_sale.product">

            <xpath expr="//div[@t-field='product.description_ecommerce']" position="after">

                <div class="oe_structure oe_variant_desc">

                    <h2>Variant Description</h2>

                    <t t-if="product.product_variant_id.website_description_variant">

                        <div id="variant_description">

                            <t t-out="product.product_variant_id.website_description_variant"/>

                        </div>

                    </t>

                </div>

            </xpath>

        </template>

    </data>

</odoo>

the important manifest stuff:

'depends': ['website_sale', 'website', 'web', 'web_editor'],

    'data': [

        'views/product_variant_description_views.xml',

        'views/product_variant_description_website.xml',        

    ],

    'assets': {

        'web.assets_frontend': [

            'product_variant_description/static/src/js/product_variant_description.js',

        ],

    },


And it works perfectly to show the first variant description. But then it is shown at every variant and is not refreshed anyhow.


I've added this js file (which seems to be the problem)

console.log('[product_variant_description] JS loaded!');


odoo.define('product_variant_description.variant_description', ['web.public.widget'], function (require) {

    "use strict";


    var publicWidget = require('web.public.widget');


    publicWidget.registry.ProductVariantDescription = publicWidget.Widget.extend({

        selector: '#variant_description',

        events: {

            'change_variant': '_onVariantChange',

        },

        _onVariantChange: function (ev) {

            const variantDesc = data.combination_info.variant_description || '';

            data.$container.find('#variant_description').html(variantDesc);

        },

    });


    return publicWidget.registry.ProductVariantDescription;

});


but it only produces errors like The following modules are needed by other modules but have not been defined, they may not be present in the correct asset bundle: ['web.public.widget']​ and does not console log anything at all. I've tried almost all approaches i could find but failed miserably.


TLDR: I would love any suggestions on how to achieve unique product variant descriptions shown on the ecommerce site.

If someone is familiar with development of odoo modules then I'd be glad to learn more, as custom portal extensions are rather omitted in tutoprial/docs  

0
Avatar
Buang
Avatar
Kasper
Penulis Jawaban Terbai

sooo by the time it got posted I've sorted it out (Browsed through odoo code) 

here is the working js implementation:

/** @odoo-module */

import publicWidget from "@web/legacy/js/public/public_widget";


publicWidget.registry.WebsiteSale.include({


    /**

         * @override

         */

    _onChangeCombination(ev, $parent, combination) {

        const res = this._super.apply(this, arguments);


        const variantDesc = combination?.website_description_variant || '';

        this.$('#variant_description').html(variantDesc);



        return res;

    },

});


might share a module on github soon 

1
Avatar
Buang
youssef tarhri

Hi, thank you, did you already share the module in github?

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
extend the functionality of the module website_sale_stock
development ecommerce
Avatar
0
Mei 24
3097
IndexError: list index out of range from Customer Portal from invoice
portal ecommerce
Avatar
Avatar
Avatar
Avatar
Avatar
4
Feb 17
8711
Importable Module Controller (Using XML Data Files)
webclient development debug
Avatar
0
Apr 25
1348
web_editor add font size options in texts
webclient development configuration
Avatar
0
Jan 25
1791
How to make the enter key work as tab key? Diselesaikan
webclient development jquery
Avatar
Avatar
Avatar
Avatar
4
Agu 22
33725
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