Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Procházet všechna odvětví
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Služby pro partnery
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

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

Odebírat

Get notified when there's activity on this post

This question has been flagged
inheritjsOdoo12.0
1 Odpovědět
18523 Zobrazení
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
Zrušit
Avatar
Jigar Patel
Nejlepší odpověď

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
Zrušit
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?

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
how to inherit or override a funtion in odoo javascript
function inherit js odoo17
Avatar
0
říj 24
2167
How to inherit js file tax_group.js (account) in odoo 13
inherit js overwrite odoo13.0
Avatar
0
pro 23
2064
inherit/extend a js function
javascript inherit js extend
Avatar
0
zář 23
3260
Inherit Java Script file
javascript inherit js extend
Avatar
Avatar
2
bře 15
7977
Custom Dashboard using js
Odoo12.0
Avatar
Avatar
1
dub 25
4597
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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