콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

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()

        }



아바타
취소
베스트 답변

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

아바타
취소
작성자

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

관련 게시물 답글 화면 활동
0
4월 24
2047
0
11월 23
1666
1
3월 24
1474
1
8월 23
4731
1
7월 23
2187