Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Diskusi
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

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

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

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

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
qweb-report
2 Replies
11046 Tampilan
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
Buang
Avatar
bunhin
Penulis Jawaban Terbai

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
Buang
Avatar
Daniel Rodriguez
Jawaban Terbai

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
Buang
Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
How to create a report with a custom chart and use the chart in the QWEB report?
qweb-report
Avatar
0
Jan 24
2257
Curious to know how the same variable show different values under the same loop in Qweb.
qweb-report
Avatar
0
Jan 24
1947
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
Des 15
5814
How to Display Monetary Field in Odoo 15 Qweb Report? Diselesaikan
qweb-report odoo15CE
Avatar
Avatar
1
Feb 25
2612
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

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