Odoo Help

1

0
3 Answers
0
Jared
21‏/3‏/2019 1:51 م

Ok, so this probably isn't the best way of doing it, but it worked for me.  I used pythons inbuilt lxml and requests modules to scrape a login session and to manually download the pdf's


import requests
from lxml import html


def __download_report(self, invoice_ids, date_to_use):
session_requests = requests.session()
login_url ="https://odoo.example.com/web/login"
result = session_requests.get(login_url) tree = html.fromstring(result.text)
authenticity_token = list(set(tree.xpath("//input[@name='csrf_token']/@value")))[0]
payload ={"login":"username","password":"password","csrf_token": authenticity_token
}
result = session_requests.post(
login_url,
data = payload,
headers = dict(referer=login_url))for invoice_id in invoice_ids:
filename = self.__get_file_name(invoice_id) url ="https://odoo.example.com/report/pdf/account.report_invoice/"+str(invoice_id)
pdf = session_requests.get(
url,
stream=True)
sys.stdout.write("\r[%s]"% filename )
sys.stdout.flush()
self.__save_report(pdf, filename, date_to_use)def __save_report(self, report_data, filename, date_to_use):with open(filename,'wb')as f:
f.write(report_data.content)
0
Avatar

Sudhir Arya (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
15099
| 8 8 10
Ahmedabad, الهند
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

• Active Memeber On Stackoverflow 

LinkedIn

Blog

Stackoverflow

ERP Harbor Consulting Services

Skype:sudhir@erpharbor.com
Website: http://www.erpharbor.com
Sudhir Arya (ERP Harbor Consulting Services)
21‏/3‏/2019 10:15 ص

From v11 onward, the report feature has been moved to base module. But still the methods are available in "ir.actions.report" object. You can use "render_qweb_pdf" method to get the binary content of the report from the code.

Here is an example how to get the content of the report

1 Comment
Jared
21‏/3‏/2019 10:56 ص

I don't really understand what's going on here. I just want access to reports like I had via https://www.odoo.com/documentation/9.0/api_integration.html the XML-RPC. Or is there a simpler way of downloading all the reports?

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 E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now