Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • eLearning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Conocimientos
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

Show variant specific description on product site ecommerce

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
webclientdevelopmentportalecommerce
1 Responder
2236 Vistas
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
Descartar
Avatar
Kasper
Autor Mejor respuesta

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
Descartar
youssef tarhri

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

¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
extend the functionality of the module website_sale_stock
development ecommerce
Avatar
0
may 24
3135
IndexError: list index out of range from Customer Portal from invoice
portal ecommerce
Avatar
Avatar
Avatar
Avatar
Avatar
4
feb 17
8744
Importable Module Controller (Using XML Data Files)
webclient development debug
Avatar
0
abr 25
1370
web_editor add font size options in texts
webclient development configuration
Avatar
0
ene 25
1843
How to make the enter key work as tab key? Resuelto
webclient development jquery
Avatar
Avatar
Avatar
Avatar
4
ago 22
33784
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y totalmente integrado.

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