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

Extend an existing js function in odoo. Now can I achieve this?

Suscribirse

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

Se marcó esta pregunta
inheritjsOdoo12.0
1 Responder
18597 Vistas
Avatar
Paulo Matos

Hello everyone,

I need your help on inheriting and extending a code on a js file for the account module.
For your reference I am using Odoo 12.

PS: I am sorry but I am unable to post images and code since some weeks ago on the forum.

The code I want to extend is from the account module and is located on the file "static/src/js/reconciliation/\reconciliation_renderer\.js\\"\ for\ the\ function\ \"_renderCreate\"\ on\ line\ \531\\.\
\
On\ this\ function\,\ starting\ from\ the\ line\ \
569 we have:

      account_id: {
         string: _t("Account"),
         domain: [['deprecated', '=', false]],
     },

Here, I just need to change the domain to something else.

What I have done:

1. Defined a template in my module to add the js asset that is located under mymodule/static/src/js/custom_asset.js:

      <template id="mymodule_asset_backend" name="custom assets" inherit_id="web.assets_backend">
         <xpath expr="." position="inside">
             <script type="text/javascript" src="/mymodule/static/src/js/custom_asset.js"></script>
         </xpath>
      </template>

2. Added the "xml" do the manifest file.

Now I need to add the required code to the js file but I do not know how to do it.

I know I have to do something like:

      odoo.define('mymodule.ReconciliationRenderer', function (require) {
      "use strict";

      var FieldManagerMixin = require('web.FieldManagerMixin');
      var LineRenderer = Widget.extend(FieldManagerMixin, {

      _renderCreate: function () {
            /* Custom code goes here */
      }, });
      return { LineRenderer: LineRenderer, };
      });

Can you please help me write this js file?

Thank you all in advance

Best regards

PM

0
Avatar
Descartar
Avatar
Jigar Patel
Mejor respuesta

Hello Paulo Matos,

It's not easily Overridable. The best way to do this is to replace whole method with changed domain.

Something like:

​odoo.define('mymodule.ReconciliationRenderer', function (require) {
"use strict";

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

var LineRenderer = Widget.extend(FieldManagerMixin, {
_renderCreate: function () {
// Copy whole code of _renderCreate method and Paste here. Just change your domain for account_id.
// Note: Don't call super
},
});

return { LineRenderer: LineRenderer, };

});

It will be risky to do such kind of messy code but it will works and fit to your needs.

1
Avatar
Descartar
Paulo Matos
Autor

Dear @Jigar Patel,

Thank you very much.

It worked as expected.

I had to "paste" the full content of "LineRenderer" because pasting just the "_renderCreate" function did not worked for me (when refreshing Odoo, just see a blank page on browser).

As you stated, perhaps it is not the best solution but for this specific case will do the job.

If I find any additional solution for solving this just by replacing the exact part the code I need, I will post it here.

Thank you once again

Best regards

PM

Pratik Devmurari

In this, what about a Widget?

Emmanuel Cruz Rangel

@Jiral Patel hi, i'm trying to extend _onSwitchCompanyClick in switch_company_menu.js but i cant get it, Could you help me please?

¿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
how to inherit or override a funtion in odoo javascript
function inherit js odoo17
Avatar
0
oct 24
2237
How to inherit js file tax_group.js (account) in odoo 13
inherit js overwrite odoo13.0
Avatar
0
dic 23
2106
inherit/extend a js function
javascript inherit js extend
Avatar
0
sept 23
3301
Inherit Java Script file
javascript inherit js extend
Avatar
Avatar
2
mar 15
8071
Custom Dashboard using js
Odoo12.0
Avatar
Avatar
1
abr 25
4684
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