Reputation: 726
My problem:
Monthly I have to export specific data to a predefined Exel sheet. It can be compared with a monthly report. However it has to be put in an Excel sheet with predefined styling and configurations. I could create a module that exports in this format but unfortunately thats not an option because the Excel file is being changed and adjusted from month to month by another department in the company.
Optimal solution:
The best way would be to have an option to import the file into odoo and then select the cells so odoo knows where to put which data. If a new Excel file is created by the other department it just needs to be uploaded to odoo and the module will replace the old file.
Obviously this needs to be done by creating a custom module. However it would be good to know if this would even be possible?
Upvotes: 0
Views: 1010
Reputation: 1068
Of course, it can be done!
You will need to write a class method that generates your Excel file using either XlsxWriter (https://xlsxwriter.readthedocs.io), OpenPyXL (https://openpyxl.readthedocs.io) or some other library capable of handling Xlsx files (https://xlsxwriter.readthedocs.io/alternatives.html)
Then you can call it by using a scheduled action
or from another python script (see <path_to_v12>/addons/mail/static/scripts/odoo-mailgate.py
to get an idea) triggered by the operating system's cron.
The tricky part is making the configuration user-friendly. I would suggest: First, take advantage of the ir_model_data
model to point to whatever you need (tables, fields, records); Second, add a sequence
field to the model holding the configuration and use <field name="sequence" widget='handle'/>
in the form view definition so users can drag and drop to reorder the fields.
By the way, creating a custom module is a good idea.
Upvotes: 1