We have added some extra fields to the model sale.order.line. The values in these fields are needed for some automatic calculations we do in our modules. Our code looks similar to this (minimal example):
class sale_order_line(models.Model):
_inherit = 'sale.order.line'
myfield1 = fields.Char(string='License key', required=False)
myfield2 = fields.Date(string='Start date', required=False)
However we need to show these values on the printed sale order as well. Therefore we tried to extend the sale order template to include these values right behind the name field. This looks like follows:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="my_report_saleorder_document" inherit_id="sale.report_saleorder_document">
<xpath expr="//span[@t-field='l.name']" position="after">
<span t-field="l.myfield1"/>
<span t-field="l.myfield2"/>
</xpath>
</template>
</data>
</openerp>
Unfortunately this extended template seems to have no effect. Odoo still uses the standard template and our custom fields are not shown. How can we tell Odoo to use the modified template?
EDIT: In the meantime we investigated a little more on the inner workings of sale order printing. It seems to be the case that Odoo has a template 'sale.report_saleorder' which in turn includes the template 'sale.report_saleorder_document':
<template id="report_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_saleorder_document')"/>
</t>
</t>
</template>
Our inherited version of the included template of course has a different ID 'mymodule.my_report_saleorder_document'. Maybe the problem is that the "master template" still includes the old version of the "inner template" instead of our new inherited version? But this would mean that there are two different types of "inheritance" in Odoo? Also the module sale_layout seems to do it the same way we do it? We are confused...