Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
1172 Vistas

Hello to everyon, 

I'm ritting this post to see if someone is able to tell me how to conect a pdf with the fields 


This is the code but this is just printing the h1 and the p 


   

       

            string="Reporte Personalizado"

            model="account.move"

            report_type="qweb-pdf"

            name="custom.report_custom_template"

        />


       

           

               

                   

                        Mi empresa  / Logo

                   

   

                   

                       

Hola

                       

Hola que tal

                   

   

                   

   

               

           

       

        

   


 

i want it to print the filds like the code of the invoice, the date, the prrice, the client...

Avatar
Descartar
Mejor respuesta

Hello Samuel ,


  • You want to print fields of model into report so you can achieve this like below,

So first of all you have to create a .py file into a report folder and import this file into _init_.py file of report folder and then  import report folder into your main _init_.py file like,

from . import report 

  • Create .py file into report folder  like below,


.py file


from odoo import models, fields, api

from datetime import datetime


class report_invoice(models.AbstractModel): 

    _name = 'report.custom_module_name.report_invoice_template


@api.model

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

        docs = self.env['account.move'].browse(docids)

        return {

            'doc_ids': docs.ids,

            'doc_model': 'account.move',

            'docs': docs, 

       }



  • Here report_invoice_template is report template id that you create into report template view file


  • Now first  create  report menu file like below and give name it report_menu.xml,

And give a path to this file into your manifest file.



  • Now create report template view file like below and give name it invoice_report_template.xml

And give a path to this file into your manifest file.




  • So here this way , You can access fields of the model into a pdf report .




 I hope this is helpful to you.


 Thanks & Regards,

 Email: odoo@devintellecs.com

 Skype: devintelle

Avatar
Descartar
Autor Mejor respuesta

Oh sorry yes it is rendered 

Here is the code 


  odoo

        data

            report id="report_custom"

                string="Reporte Personalizado"

                model="account.move"

                report_type="qweb-pdf"

                name="custom.report_custom_template"

            


            template id="report_custom_template"

                t t-call="report.html_container"

                    t t-call="report.external_layout"

                        div class="header"

                            Mi empresa  / Logo

                        div   

                        div class="page"

                            h1 Hola h1

                            p Hola que tal p

                        div   

                        div class="footer"

                            small Mi footer small

                        div   

                    t

                t

            template

            

        data

    odoo



Avatar
Descartar
Mejor respuesta

First of all, your code is not visible because it is rendered as html, so it is difficult to give you an answer. Try escaping the code or paste it inside a comment. If you want to know more about how to render custom pdf reports you can check out my blog post on this topic: 

https://jortdevreeze.com/blog/odoo-2/crafting-custom-document-layouts-in-odoo-a-step-by-step-guide-16

I hope this helps!

Avatar
Descartar