4

I am new to odoo, I created a module by inheriting sales_order to create a custom report. I am getting the above error when I am printing the report. Need help please?

Here is the code snippets:

test/my_module.py:

class sale_order(models.Model):
   _name = 'sale.order'
   _description = 'Inheritance'
  _inherit = 'sale.order'

test/views/report_template_view.xml:

<?xml version="1.0" encoding="utf-8"?>
    <openerp>
        <data>
            <template id="test_report">
                <t t-call="report.html_container"> 
                <t t-call="report.internal_layout"> 
                <t t-set="doc" t-value="doc.with_context({'lang':doc.partner_id.lang})"/> 
                <div class="page"> 
                    <div class="oe_structure"/> 
                        <div> <strong><left>User</left></strong> 
                            <p t-field="doc.user_id"/> 
                        </div> 
                     </div> 
            </t> 
           </t>
   </template>
</data>

How can I access records in custom_report_template?

Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
Arshad
  • 61
  • 1
  • 5

1 Answers1

2

i know i'm late but the name of the variable containing the recordSet passed to the template is docs not doc. and you are trying to get value from a variable that don't have anything.

doc.with_context({'lang':doc.partner_id.lang})

i think you need to do docs not doc because doc is None This why all template in loop docs :

   <t t-foreach="docs" t-as="o">
Charif DZ
  • 14,415
  • 3
  • 21
  • 40