Odoo Help

0

0
3 Answers
0
Samo Arko
25‏/5‏/2018 5:26 ص

After finding out that I need to use the method "get_pdf()" I found the answer.

https://www.odoo.com/forum/help-1/question/how-to-programmatically-create-pdf-attachment-in-odoo-10-0-118073

def generate_report_file(self):
        report_name = "hr_izracun_place.report_placilna_brez_prisp"
        pdf = self.env['report'].sudo().get_pdf([self.id], report_name)
        self.report_file = base64.encodestring(pdf)

After I just created a method that creates a string that ends with .pdf for the file name and stores in a field and added to my view.

<field name="file_name" invisible="1"/>
<field name="report_file" filename="file_name"/>
0
Avatar

Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
7752
| 7 8 10
Rajkot, الهند
--Emipro Technologies Pvt. Ltd.--

Emipro has been providing a wide range of business solutions in the domain of ERP & eCommerce. We take pride in serving 1000s of contented customers across the globe with strong roots in the US, Europe & India. Being a Certified Odoo Gold Partner in India as well as the United States, we bring our rich professional experience and unrivaled technical competence to help our customers obtain efficient and cost-effective business solutions in Odoo. With our team of 50+ Odoo Experts and highly experienced business analysts, we serve our customers which are companies of all sizes, ranging from start-ups to large enterprises. 

Our ERP Services:

  • Business Need Analysis & GAP Analysis

  • ERP Migration

  • Odoo Consultancy

  • Odoo Implementation & Customization

  • Odoo Training & Support

  • Odoo Website & eCommerce Development

  • Odoo Integration (Marketplaces, eCommerce platforms, Shipping Carriers, Payment Gateways etc.)

Our Achievements:


Reach Us:

Website: www.emiprotechnologies.com

Email: info@emiprotechnologies.com

Skype: emiprotech

Emipro Technologies Pvt. Ltd.
25‏/5‏/2018 12:38 ص

Hello Samo,

You can add report as attachment in your record, when generating report.

To add attchment of report in record, you can add "attachment" in report XML as did in invoice report: 

<report 
            id="account_invoices"
            model="account.invoice"
            string="Invoices"
            report_type="qweb-pdf"
            name="account.report_invoice_with_payments"
            file="account.report_invoice_with_payments"
            attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
            print_report_name="(object._get_printed_report_name())"
     />

Thanks,


1 Comment
Tabla d.o.o., Samo Arko
25‏/5‏/2018 4:35 ص

I don't think this does what I asked. I need to save it into a binary field of an X model and I need this to be done in the python code. To have a model where all documents are stored. In the example you posted I can't find to what field it's stored.

Ask a Question
Writer
Keep Informed
1 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our eLearning platform and experience all Odoo Apps through learning videos, use cases and quizzes.

Test it now