Help

0

Export xls files with automated actions to an ftp file server

Hello everyone, could someone guide me on whether there is the possibility of creating a kind of automatic action in odoo where what is done is to export xls files on the records of a defined model and send the file to an ftp server? As if it were the export action from Odoo but do it automatically and store it in a specific place.

Avatar
Discard
1 Answer
0
Avatar
Ibrahim Boudmir
Best Answer

Hi, 
I've done something similar. the solution is quite easy if you follow these steps: 

1- Create your Scheduled or automated action with code record.function1()
2-  in function1(), get the records you want to export. 
3- add sub_function export_xls you your function1 where you only add export process of the records you got.
4- google how to export xls in python, there are plenty of blogs. I use xlsxwriter
5 - function sub_function returns a path to your xls file.
6- use pysftp with your given credentials to open a session. there are also lots of blogs that talk about pysftp.
7- session.put(path) where path is the return of sub_function
8- check your file in your sftp space with : sftp -P port  user@domain

Hope this helps.

Avatar
Discard