I want add external layout header and footer on my custome report.
My custom module:
class my_module(osv.osv):
_name = "my.module"
_description = "my module"
_columns = {
'name': fields.char('Name',size=256),
'date': fields.date('Date', select=True),
'user': fields.many2one('res.users', 'User', select=True, track_visibility='onchange'),
'description':fields.html('Description'),
}
In report I'm add line external_layout from project module:
<t t-foreach="docs" t-as="doc">
<t t-call="report.external_layout">
<t t-set="doc" t-value="doc.with_context({'lang':doc.partner_id.lang})" />
<div class="page">
<div class="row">
<div class="col-xs-12 text-center"><h2><b>MY REPORT</b></h2></div>
</div>
</div>
When open report get error:
Error message:
"'my.module' object has no attribute 'partner_id'" while evaluating
"doc.with_context({'lang':doc.partner_id.lang})"
Add partner_id field into your model.
For example:
'partner_id': fields.many2one('res.partner', 'Partner', required=1)
Don't forget to add partner_id in view file.
Afterwards, restart Odoo server and upgrade your module.