#Construction/Production Company Automation
8 messages · Page 1 of 1 (latest)
Hey @modest bay, you can follow this approach. To automate the export of PDF invoices in Odoo, you can use the Odoo XML-RPC API with Python to programmatically download and save invoices as PDF files.
Here's a general approach:
Connect to the Odoo instance using the XML-RPC API:
url = 'http://localhost:8069'
db = 'my_database'
username = 'my_username'
password = 'my_password'
common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
uid = common.authenticate(db, username, password, {})```.
Create a new XML-RPC client object to interact with the Odoo ````models:
models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))```
Search for the invoices you want to download:
```invoice_ids = models.execute_kw(db, uid, password, 'account.move', 'search', [[['state', '=', 'posted'], ['type', '=', 'out_invoice']]])```
Download the PDF file for the first invoice in the list:
```invoice = models.execute_kw(db, uid, password, 'account.move', 'read', [invoice_ids], {'fields': ['name', 'invoice_date', 'amount_total']})
pdf_file = models.execute_kw(db, uid, password, 'account.move', 'invoice_print', [invoice_ids, 'pdf'])```
Save the PDF file to disk:
```filename = '{}_{}.pdf'.format(invoice['name'], invoice['invoice_date'])
with open(filename, 'wb') as f:
f.write(pdf_file)```
If you're not so technical, I can help you further to implement an effective automation.
hi have previously worked with accounting firm for there invoice automation lets connect let me know of your availability i will walk you through the live demo
I texted you private!
I texted you private!
i hope there is a api integration from odoo or else you have to rely on browser automation to do it. i never used odoo so dont have much idea but just a small suggestion from my side if browser automation is the only way