Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita 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
  • Proyectos
  • 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

Odoo10: how to replace inherited qweb template content ?

Suscribirse

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

Se marcó esta pregunta
odoo10Odoo10.0Odoo10
3 Respuestas
21118 Vistas
Avatar
peter

I have tried to insert a tag into an existing template but couldn't get it to work.

Existing template in odoo/addons/mail/static/src/xml/thread.xml

<!-- language: xml -->

    <?xml version="1.0" encoding="UTF-8"?>
    <templates xml:space="preserve">
   
        <t t-name="mail.ChatThread">
            <t t-if="messages.length">
               :
        <t t-name="mail.ChatComposer.Attachments">
            <div class="o_attachments">
                <t t-foreach="attachments" t-as='attachment'>
                    <t t-call="mail.Attachment">
                        <t t-set="editable" t-value="true"/>
                    </t>
                </t>
            </div>
        </t>

        <t t-name="mail.Attachment">
            <div t-attf-class="o_attachment #{attachment.upload ? 'o_attachment_uploading' : ''}" t-att-title="attachment.name">
   
                <a class="o_image" t-att-href='attachment.url' target="_blank" t-att-data-mimetype="attachment.mimetype" t-attf-data-src="/web/image/#{attachment.id}/100x80">
                    <span class='o_attachment_name'><t t-esc='attachment.name'/></span>
                </a>
                <t t-if="editable">
                    <div class="o_attachment_delete">
                        <i class='fa fa-times-circle' title="Delete this attachment" t-att-data-id="attachment.id"/>
                    </div>
                    <div class="o_attachment_progress_bar">
                        Uploading
                    </div>
                </t>
            </div>
        </t>

My custom template (odoo/addons/mycustom/static/src/xml/thread.xml):<br>
I want to insert the Hello world after the class o_image in the original template.

<!-- language: xml -->

    <?xml version="1.0" encoding="UTF-8"?>
    <templates xml:space="preserve">
        <t t-name="mycustom.ImageAttachment" t-extend="mail.Attachment">
            <t t-jquery="o_image" t-operation="append">
                <div>Hello world</div>
            </t>
        </t>
    </templates>

My javascript to render the template (odoo/addons/mycustom/static/src/js/thread.js):

<!-- language: lang-js -->

    odoo.define('mycustom.thread', function (require) {
    "use strict";
   
    var core = require('web.core');
    var ajax = require('web.ajax');
    var qweb = core.qweb;
   
    ajax.loadXML('/mycustom/static/src/xml/thread.xml', qweb);
    console.log("INFO", "Hello World")
   
    });

My assets file (odoo/addons/mycustom/views/assets.xml):

<!-- language: xml -->

    <?xml version="1.0" encoding="utf-8"?>
    <odoo>
        <template id="assets_backend" name="my assets" inherit_id="web.assets_backend">
          <xpath expr="." position="inside">
              <script type="text/javascript" src="/mycustom/static/src/js/thread.js"></script>
          </xpath>
        </template>
    </odoo>

My manifest file (odoo/addons/mycustom/__manifest__.py):

<!-- language: python -->

    # -*- coding: utf-8 -*-
    {
        'name': "test",
   
        'summary': """my test""",
   
        'description': """
            This is my test module.
        """,
   
        'author': "peter",
        'website': "",
   
        # Categories can be used to filter modules in modules listing
        # Check https://github.com/odoo/odoo/blob/master/odoo/addons/base/module/module_data.xml
        # for the full list
        'category': 'Test',
        'version': '0.1',
   
        # any module necessary for this one to work correctly
        'depends': ['base','mail'],
   
        # always loaded
        'data': [
            'views/assets.xml',
        ],
       
        'qweb': [
            'static/src/xml/thread.xml',
        ],
       
    }

The javascript is loaded because I can see the text `Hello World` written on the browser console.
However, I cannot see the `<div>Hello World</div>` in the chat thread. What did I miss?

0
Avatar
Descartar
peter
Autor

sorry for the bad formatting guys, i tried to re-format the code block for my question but i got the 403 - Forbidden reply from Odoo and couldn't update my changes.

Avatar
Daniel Lopez
Mejor respuesta

Hi Peter,

I found a problem with t-query selector, o_image is not found because it's a class, try with .o_image 


<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
    <t t-name="mycustom.ImageAttachment" t-extend="mail.Attachment">
        <t t-jquery=".o_image" t-operation="append">
            <div>Hello world</div>
        </t>
    </t>
</templates>

Let me know if your problem was fixed

Daniel

0
Avatar
Descartar
Avatar
Andrea Alessandrini
Mejor respuesta

See this answer

https://www.odoo.com/es_ES/forum/ayuda-1/question/replace-all-qweb-template-using-inheritance-94325


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

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

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
could not execute command lessc in odoo 10 Windows Resuelto
odoo10 Odoo10.0
Avatar
Avatar
Avatar
3
mar 18
16040
leave management odoo 10
odoo10 Odoo10.0
Avatar
Avatar
1
sept 17
3548
How to hide a measure(field) in odoo10 grph view
odoo10 odoo10.0 odoo10e Odoo10.0 Odoo10
Avatar
Avatar
1
mar 21
4838
How odoo identify which record they have to return the value of name_search method?
name_search odoo10 odoo10.0 Odoo10.0 Odoo10
Avatar
0
jul 17
4490
How to print an excel file from form view without using wizard Resuelto
openerp odoo10 Odoo10.0
Avatar
Avatar
Avatar
2
abr 18
8743
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • 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 estar totalmente integrado.

Sitio web hecho con

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