#Construction/Production Company Automation

8 messages · Page 1 of 1 (latest)

modest bay
#

Hey everyone,
im trying to automate our small family business. We work with Odoo v16 as our CRM, ERP, everything programm. Right now im Trying to Automate the PDF Export for Invoices but there is not much Info on Odoo.

twin spire
#

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.
wooden goblet
heavy frigate
modest bay
#

Der is an Integration already in n8n

#

"There"