'Manually create files from rendering odoo qweb
Question: How can I create in python a pdf file using qweb, like Jinja with render_template(template, context)?
Problem explained:
Hello, I'm new to Odoo.
I have to create a wizard which create a folder with different reports, and make it accessible in the following download view.
Folder structure to zip and download:
expenses_report
├── EMPLOYEE1_04-56,8
│ ├── expenses_report_EMPLOYEE1_04_56,8.pdf
│ ├── internet_bill.pdf
│ ├── meal_justificative.pdf
│ └── transport_bill.pdf
└── EMPLOYEE2_04-25,6
├── another_justificative.jpg
└── expenses_report_EMPLOYEE2_04_25,6.pdf
As you can see, I have to do a bit of python, but that's not the problem.
For the expenses_report, I have to take the qweb report linked to the "Print" button on expenses view, BUT I have to put many expenses that where query-ed in python on wizard click.
So, you can now read again the question
PS: my pseudo code:
@api.multi
def export_new_expenses(self):
attachments_by_employee = self._get_new_attachments()
self._copy_attachments_in_tmp_folder(attachments_by_employee)
self._create_expense_reports(attachments_by_employee)
file_record = self._create_zip_file_record()
return self._download_view(file_record)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
