I have read odoo official documentation on Qweb Report but still not clear enough if i want to add or modify the layout of qweb pdf report by through a custom module, especially which file to place the mentioned code in the documentation, and to which folder i should place the file? I search the web a lot for this but almost all of them just mimic the official doc without adding this lack of information.
to be more tangible i would like to have an example:
said i want to add new sales order pdf report for sales order or quotation, name it as "Custom Quotation/Order" this new report :
1.change the layout above the table (positioning)
2.and in below of the table, add "total amount before discount", "total amount of discount" add "amount to text" as well other text div.
I want to do it by creating a custom modul named "sale_order_custom", so from standard module structure and from learning a sale module structure i create module structure :
addons/sale_custom_report/
|-- __init__.py
|-- __openerp__.py
|-- sale_custom_report_report.xml
|-- models/
| |-- __init__.py
| `-- sale_order_custom.py
|-- report/
| |-- __init__.py
| |-- ??
|-- views/
| |-- report_custom_saleorder.xml
in file sale_order_custom_report.xml i put the following code:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<report
id="report_custom_sale_order"
string="Custom Quotation / Order"
model="sale.order"
report_type="qweb-pdf"
file="sale_order_custom.report_custom_saleorder"
name="sale_order_custom.report_custom_saleorder"
/>
</data>
</openerp>
in file report_custom_salorder.xml i put the following code:
<?xml version="1.0"?>
<openerp>
<data>
<template id="report_custom_saleorder">
<t t-call="report.html_container">
<t t-foreach="doc_ids" t-as="doc_id">
<t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'sale.report_custom_saleorder_document')"/>
</t>
</t>
</template>
<template id="sale.report_custom_saleorder_document">
<t t-call="report.external_layout">
<div class="page">
<!--Report Architecture -->
<div class="row">
......
......
</div>
</div>
</t>
</template>
</data>
</openerp>
in /models/ sale_order_custom.py i put the following code:
# -*- coding: utf-8 -*-
from openerp import models, fields, api
from openerp.tools import amount_to_text
class sale_order(models.Model):
_inherit = 'sale.order'
@api.multi
def amount_to_text(self,amount,currency='Idr'):
return amount_to_text(amount,currency)
But i am not sure whether it correct to put it under models folder, and what to put in /report/ folder ?
in __openerp__.py i put below code:
# -*- coding: utf-8 -*-
{
'name': "custom_sale_order",
'summary': """
Short (1 phrase/line) summary of the module's purpose, used as
subtitle on modules listing or apps.openerp.com""",
'description': """
Long description of module's purpose
""",
'author': "Your Company",
'website': "http://www.yourcompany.com",
'category': 'Uncategorized',
'version': '0.1',
'depends': ['base','sale'],
'data': [
'models/sale_custom_report.py',
'views/report_custom_saleorder.xml',
'report/<?????>',
'sale_order_custom_report.xml',
],
}
Please somebody help to get all file correctly coded, i believe this will help others people learning to build qweb report from module correctly and respecting odoo module structure.