Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

ValueError. How to customize a Qweb report properly by replacing "div[@class='page']"?

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
qwebinheritreportodoo10
5 Risposte
27690 Visualizzazioni
Avatar
Art

I'm trying to customize a report_invoice_document qweb report. Here is the source code:

<?xml version="1.0"?>
<t t-name="account.report_invoice_document">
<t t-call="report.external_layout">
<t t-set="o" t-value="o.with_context({'lang':o.partner_id.lang})"/>
<div class="page">
    <div class="row">
        <div name="invoice_address" class="col-xs-5 col-xs-offset-7">
            <address t-field="o.partner_id" t-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;], &quot;no_marker&quot;: True}"/>
            <span t-if="o.partner_id.vat">TIN: <span t-field="o.partner_id.vat"/></span>
        </div>
    </div>
<h2>
    <span t-if="o.type == 'out_invoice' and (o.state == 'open' or o.state == 'paid')">Invoice</span>
    <span t-if="o.type == 'out_invoice' and o.state == 'proforma2'">PRO-FORMA</span>
    <span t-if="o.type == 'out_invoice' and o.state == 'draft'">Draft Invoice</span>
    <span t-if="o.type == 'out_invoice' and o.state == 'cancel'">Cancelled Invoice</span>
    <span t-if="o.type == 'out_refund'">Refund</span>
    <span t-if="o.type == 'in_refund'">Vendor Refund</span>
    <span t-if="o.type == 'in_invoice'">Vendor Bill</span>
    <span t-field="o.number"/>
</h2>
...

So I'm trying to replace "div[@class='page']" and build my own report with the following code and expect to see just the "Invoice_test_2" in my report when I print it out:

<odoo>	
    <data>
        <template id="practichem_report_invoice_layout" inherit_id="account.report_invoice_document">
            <xpath expr="//div[@class='page']" position="replace">
                <div class="page">
                    <h2>Invoice_test_2</h2>
                </div>
            </xpath>
        </template>
    </data>
</odoo>

But I'm getting the following error:

ValueError: Can't validate view:
Element '<xpath expr="//div[@name='invoice_address']">' cannot be located in parent view

What am I doing wrong?


1
Avatar
Abbandona
Art
Autore

However, I can replace the <h2> tag with the following code and it works:

<template id="practichem_report_invoice_layout" inherit_id="account.report_invoice_document">

<xpath expr="//div[@class='page']//h2" position="replace">

<h2>Customer Invoice Report</h2>

</xpath>

</template>

Avatar
Marius Stedjan
Risposta migliore

The reason for the error is that other templates ("report_invoice_document_inherit_sale", "account_invoice_report_duplicate", "report_invoice_document_inherit_sale" and "report_invoice_layouted") are already inheriting the account.report_invoice_document template.
When you inherit it yourself and remove the code that the inheriting templates are looking for, Odoo throws an error.. because it can't find the code.

The solution I found was to first make a new template inheriting "account.report_invoice" (this is the template calling the "account.report_invoice_document" on every document), and make this new template call my custom report_invoice_document template/report.

Something like this:

Inherit account.report_invoice to make it call my custom template/report:

<template id="report_invoice_inherit_mymodule" inherit_id="account.report_invoice">
<xpath expr="//t[@t-call='account.report_invoice_document']" position="replace">
            <t t-call="mymodule.report_invoice_document" t-lang="o.partner_id.lang"/>
</xpath>
</template>

Create new template for report_invoice_document

<template id="report_invoice_document">
<t t-call="report.external_layout">
<t t-set="o" t-value="o.with_context({'lang':o.partner_id.lang})" />
<div class="page">
My Custom Report Here...
</div>
</t>
</template>
3
Avatar
Abbandona
SonnyV

+1 for including a code-example of the suggested solution ;)

SHIV SHANKAR

Thanks for saving my day!! :)

Paolo M

Don't work on odoo 12, i have this error message:

Error to render compiling AST

AttributeError: 'dict' object has no attribute 'type'

Template: 1151

Path: /templates/t/t/t/t[1]

Node: <t t-set="lang" t-value="o.user_id.sudo().lang if o.type in ('in_invoice', 'in_refund')

Avatar
Art
Autore Risposta migliore

So I added attribute primary=”True” inside the <template> tag and error was gone. But now no matter what I do with the report customization it doesn't affect anything and it prints out the original report.

So I still have a problem with the report inheritance.

1
Avatar
Abbandona
SonnyV

primary="True" Means your report does not inherit from any other report. So Xpath expressions are of no use here since you just told Odoo this report is a new one.

This could be good, but then you will need to update the action (clicking the print invoice button for example) to call your new report and not the original invoice-layout.

Avatar
SonnyV
Risposta migliore

Hello Art

The problem you are facing here is because you are replacing the entire page and another installed module inherits a part of this page you are replacing.

I checked the github odoo10 code and searched for <xpath expr="//div[@name='invoice_address']">
This made me notice the file addons/sale/report/invoice_report_templates.xml

In this file they inherit the report you are trying to inherit. When you update your module the invoice report gets reloaded and all it's 'children' as well. Since you remove everything from the report, Odoo is unable to validate the view in the sale addon above, since the xpath is looking for something inside the page and that is gone now, since the xml only consists of the page and the h2.

SO, you can test if I am right or not by adding a div with name invoice_address to your page, then install or update your module, this should solve your error, but you have an unwanted div in the report now.

What I would suggest is that you create a whole new report and an action, or find out how to make the existing action link to another xml file (your new xml file).

The problem with creating a whole new action would be that when you send the invoice by mail, the default layout would still be called and not your new one, so if you decide to go this road, bear in mind that there are references that should also be updated.


I hope I helped you or at least gave you a push in the right direction.

Sincerely

Sonny V.
ERP-consultant @ Cats and Dogs, BE


0
Avatar
Abbandona
Marius Stedjan

Wow.. we replied at exactly the same time :-D

Check my answer for a solution to the "new action" problem.

Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
[V.10] How to add Google Font in report odoo
qweb report odoo10
Avatar
Avatar
1
nov 17
6641
Change pdf file name in report definition Odoo 10 Risolto
qweb report odoo10
Avatar
Avatar
Avatar
Avatar
4
ott 17
27259
Inherit Qweb Risolto
v8 qweb inherit report
Avatar
Avatar
Avatar
Avatar
4
feb 24
49888
how to pass value of custom field to existing report and comput on it?
qweb inherit report v15
Avatar
0
mag 22
4144
odoo10: How too call an attachment in an other qweb report ?
attachment qweb report odoo10
Avatar
Avatar
1
set 19
4400
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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