Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Nekilnojamasis turtas
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Konsultavimas
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Maistas
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Saulės energijos sistemos
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Kiti
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

[✅ SOLVED] How to extend the 'documents.FileViewer' QWeb template ?

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
qwebentreprisev18
1 Atsakyti
1684 Rodiniai
Portretas
AdaLabs Ltd

EDIT: Thanks to Christoph for the answer, post refactored with the solution

Using Odoo 18 Entreprise, the goal is to modify the 'documents.FileViewer' QWeb template of Odoo Documents module, simply by adding the content 'TEST !' in the file viewer. 

The QWeb template is present in 'addons/documents/static/src/attachments/document_file_viewer.xml', and inherits from 'web.FileViewer' using 'primary' inheritance mode.

In order to validate that we can effectively extend this template, the aim is to add a simple text as a proof of success. The 'documents.FileViewer' template inherit from 'web.FileViewer' template available in 'odoo/addons/web/static/src/core/file_viewer/file_viewer.xml', which contains the div below

<div class="flex-grow-1"/>

Then our goal is to add the sequence below after the div above

<span>TEST !</span>

Thus, our QWeb template is as below

<?xml version="1.0" encoding="UTF-8"?>
<templates>
    <t-inherit="documents.FileViewer" t-inherit-mode="extension" t-name="al_documents.FileViewer">
        <xpath expr="//div[contains(@class, 'flex-grow-1')]" position="after">
            <span>TEST !</span>
        </xpath>
   </t>
</templates>

As can be read in the QWeb documentation, an in-place transformation (extension inheritance) will be applied on the existing 'documents.FileViewer' template. In this context 't-name' is not the name of a new template ! It is an optional reference added as a comment in the transformed template to retrace inheritance. 


As the Odoo Documents module manifest specifies 'documents/static/src/attachments/**/*' in the 'web.assets_backend', we will add our template in the same asset.

    'assets': {
        'web.assets_backend': [
            'al_documents/static/src/xml/patch_document_file_viewer.xml',
        ],
    },
    'depends':['base', 'web', 'documents'],



1
Portretas
Atmesti
Portretas
Christoph Farnleitner
Best Answer

If this is your full source, then no where are you telling Odoo to actually use al_documents.FileViewer as a template. You've just defined a second, additional template that is 'similar' to documents.FileViewer. 

Odoo will still only render documents.FileViewer, unless you explicitly tell it to use another one (https://github.com/odoo/enterprise/blob/18.0/documents/static/src/attachments/document_file_viewer.js#L8).

You are probably rather looking for this type of inheritance:

<t t-inherit="documents.FileViewer" t-inherit-mode="extension">
    <xpath expr="//div[contains(@class, 'flex-grow-1')]" position="after">
        <span>TEST !</span>
    </xpath>
</t>

See also https://www.odoo.com/documentation/18.0/developer/reference/frontend/qweb.html#template-inheritance


2
Portretas
Atmesti
AdaLabs Ltd
Autorius

Dear Christoph,
many thanks for your contribution !
Amazing to learn the in-place Extension inheritance.
I wrongly though that the primary mode would apply the changes to the template specified by inherit_id.
I will edit the post with your solution.
Thanks

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

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

Registracija
Related Posts Replies Rodiniai Veikla
[✅ SOLVED] How to make sure odoo.addons.base.models.ir_cron will log the number of processed records on a cronjob completion ?
python cronjob entreprise v18
Portretas
0
liep. 25
1586
Change Sign & Pay Button on Quotation E-mails
v18
Portretas
Portretas
Portretas
Portretas
3
lapkr. 25
374
Problem including JS asset in v18
v18
Portretas
Portretas
Portretas
3
lapkr. 25
8461
Is it possible to sell on credit directly at the point of sale and leave the order pending payment?
v18
Portretas
Portretas
2
rugs. 25
775
Odoo 18: Display image from char field containing url in qweb form
qweb
Portretas
Portretas
1
liep. 25
3084
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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