İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
2545 Görünümler

I need to modify the invoice report like totally change the way it looks and i have read through the odoo qweb docs (https://www.odoo.com/documentation/16.0/developer/reference/backend/reports.html)   and saw the Custom Reports section but i don't really understand how it works.


from odoo import api, models


class ParticularReport (models.AbstractModel):

    _name = 'report.module.report_name'


    def _get_report_values (self,docids,data= None ):

        # get the report action back as we will need its data

        report = self.env['ir.actions.report']._get_report_from_name('module.report_name')

        # get the records selected for this rendering of the report

        obj = self.env[report.model].browse(docids)

        # return a custom rendering context

        return {

            'lines': docids.get_lines()

        }



Avatar
Vazgeç
En İyi Yanıt

Hi,

You can try the Python code like this
from odoo import models

class ParticularReport(models.AbstractModel):
    _name = 'report.module.report_name'

    @api.model
    def _get_report_values(self, docids, data=None):
        # Retrieve the records for this report
        records = self.env[self.env.context.get('active_model')].browse(docids)

        # Define the data to pass to the report template
        report_data = {
            'records': records,  # Pass the records for template usage
        }

        return report_data

Please note that this is just the Python part of the customization. You will also need to create an XML template that defines the actual structure and layout of your report. This template should be placed in your custom module's reports folder and should be associated with the report you're customizing.
For more information, you can refer to this blog: https://www.cybrosys.com/blog/how-to-create-a-custom-pdf-report-in-odoo-16

Hope it helps

Avatar
Vazgeç
Üretici

hello. i did that but it says the record is missing when i created a new template. see my changes here: https://www.odoo.com/it_IT/forum/assistenza-1/how-to-get-passed-values-from-qweb-report-231993

İlgili Gönderiler Cevaplar Görünümler Aktivite
0
Nis 24
2143
0
Kas 23
1785
1
Mar 24
1474
1
Ağu 23
4872
1
Tem 23
2259