Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

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

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
inheritjsOdoo12.0
1 Répondre
18598 Vues
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
Ignorer
Avatar
Jigar Patel
Meilleure réponse

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
Ignorer
Paulo Matos
Auteur

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?

Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
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
déc. 23
2107
inherit/extend a js function
javascript inherit js extend
Avatar
0
sept. 23
3303
Inherit Java Script file
javascript inherit js extend
Avatar
Avatar
2
mars 15
8071
Custom Dashboard using js
Odoo12.0
Avatar
Avatar
1
avr. 25
4685
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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