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

[v8] How to create qweb pdf report correctly using a custom module

Iscriviti

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

La domanda è stata contrassegnata
qweb-report
2 Risposte
11036 Visualizzazioni
Avatar
bunhin

I have read odoo official documentation on Qweb Report but still not clear enough if i want to add or modify the layout of qweb pdf report by through a custom module, especially which file to place the mentioned code in the documentation, and to which folder i should place the file? I search the web a lot for this but almost all of them just mimic the official doc without adding this lack of information.

to be more tangible i would like to have an example:

said i want to add new sales order pdf report for sales order or quotation, name it  as  "Custom Quotation/Order" this new report :

1.change the layout above the table (positioning)

2.and in below of the table, add "total amount before discount", "total amount of discount" add "amount to text" as well other text div.

I want to do it by creating a custom modul named  "sale_order_custom", so from standard module structure and from learning a sale module structure i create module structure :

addons/sale_custom_report/

|-- __init__.py

|-- __openerp__.py

|-- sale_custom_report_report.xml

|-- models/

| |-- __init__.py

| `-- sale_order_custom.py

|-- report/

| |-- __init__.py

| |-- ??

|-- views/

| |-- report_custom_saleorder.xml

in file    sale_order_custom_report.xml     i put the following code:

    <?xml version="1.0" encoding="utf-8"?>

    <openerp>

         <data>

                <report

                    id="report_custom_sale_order"

                     string="Custom Quotation / Order"

                     model="sale.order"

                     report_type="qweb-pdf"

                     file="sale_order_custom.report_custom_saleorder"

                     name="sale_order_custom.report_custom_saleorder"

                />

            </data>

      </openerp>

in file    report_custom_salorder.xml     i put the following code:

<?xml version="1.0"?>

<openerp>

    <data>

        <template id="report_custom_saleorder">

            <t t-call="report.html_container">

            <t t-foreach="doc_ids" t-as="doc_id">

            <t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'sale.report_custom_saleorder_document')"/>

            </t>

        </t>

</template>

    <template id="sale.report_custom_saleorder_document">

        <t t-call="report.external_layout">

            <div class="page">

                <!--Report Architecture -->

                <div class="row">

                    ......

                    ......

                </div>

         </div>

      </t>

    </template>

   </data>

</openerp>

in  /models/ sale_order_custom.py    i put the following code:

# -*- coding: utf-8 -*-

from openerp import models, fields, api

from openerp.tools import amount_to_text

class sale_order(models.Model):

    _inherit = 'sale.order'

@api.multi

    def amount_to_text(self,amount,currency='Idr'):

    return amount_to_text(amount,currency)

But i am not sure whether it correct to put it under models folder, and what to put in /report/ folder ?

in  __openerp__.py  i put below code:

# -*- coding: utf-8 -*-

{

'name': "custom_sale_order",

'summary': """

Short (1 phrase/line) summary of the module's purpose, used as

subtitle on modules listing or apps.openerp.com""",

'description': """

Long description of module's purpose

""",

'author': "Your Company",

'website': "http://www.yourcompany.com",

'category': 'Uncategorized',

'version': '0.1',

'depends': ['base','sale'],

'data': [

'models/sale_custom_report.py',

'views/report_custom_saleorder.xml',

'report/<?????>',

'sale_order_custom_report.xml',

],

}

Please somebody help to get all file correctly coded,  i believe this will help others people learning to build qweb report from module correctly and respecting odoo module structure.

0
Avatar
Abbandona
Avatar
bunhin
Autore Risposta migliore

Hi Daniel Rodriguez,

Thank you for your response and guidance and help, it answer about structure, i will try it soon.

There is a function i need to call in the custom_salorder_report (i believe it is not available to call in current existing report of odoo), that is  amount_to_text_en.py function which will display amount total in text. The file is already available in openerp/tools/ folder.

the other, i need to calculate  and display the total amount before discount and total amount of discount if there is discount in order lines ( current standard report display only total of discounted amount before tax, total text, and total amount), i am not sure where to define this function correctly (inheriting sale.order model and add compute fields) or defining a function in report parser.

if i not wrong or misunderstand the documentation, we can use custom report. i quoted the documentation below :

Quote

Custom Reports

The report model has a default get_html function that looks for a model named report.module.report_name. If it exists, it will use it to call the QWeb engine; otherwise a generic function will be used. If you wish to customize your reports by including more things in the template (like records of others models, for example), you can define this model, overwrite the function render_html and pass objects in the docargs dictionary:

from openerp import api, models

class ParticularReport(models.AbstractModel):
    _name = 'report.module.report_name'
    @api.multi
    def render_html(self, data=None):
        report_obj = self.env['report']
        report = report_obj._get_report_from_name('module.report_name')
        docargs = {
            'doc_ids': self._ids,
            'doc_model': report.model,
            'docs': self,
        }
        return report_obj.render('module.report_name', docargs)

Unquote

Please share and help how to do it in each  method? and which method is preferable / better?

 

0
Avatar
Abbandona
Avatar
Daniel Rodriguez
Risposta migliore

Hi, I think yout structure is not correctly.

The correctly structure must be:

1.__init__.py

1.__openerp__.py

1.reports

2.sale_custom_report_report.xml

With this should be enough.

In __openerp__.py, you can add to data attribute:

'data': [

'reports/sale_custom_report_report.xml',

]

in sale_custom_report_report.xml at the bottom os this file you can add this:

<template id="report_custom_saleorder">

<t t-call="report.html_container">

<t t-foreach="doc_ids" t-as="doc_id">

<t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'sale.report_custom_saleorder_document')"/>

</t>

</t>

</template>

<report

id="report_custom_sale_order"

string="Custom Quotation / Order"

model="sale.order"

report_type="qweb-pdf"

file="sale_order_custom.report_custom_saleorder"

name="sale_order_custom.report_custom_saleorder"

attachment="(object.state in ('open','paid')) and ('Example_report_'+(object.number or '').replace('/','')+'.pdf')"

/>


With this could be enought, but if you have any problem tell me and I try yo help you

0
Avatar
Abbandona
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à
How to create a report with a custom chart and use the chart in the QWEB report?
qweb-report
Avatar
0
gen 24
2254
Curious to know how the same variable show different values under the same loop in Qweb.
qweb-report
Avatar
0
gen 24
1944
Error al imprimir un Qweb (espacio en blanco al principio de la hoja)
qweb-report
Avatar
0
feb 22
2955
Custom QWEB report in a module
qweb-report
Avatar
Avatar
Avatar
2
dic 15
5811
How to Display Monetary Field in Odoo 15 Qweb Report? Risolto
qweb-report odoo15CE
Avatar
Avatar
1
feb 25
2610
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