title: Odoo 11 Qweb Custom Report : Error to render compiling AST TypeError: 'NoneType' object is not callable
body: <p>My first time publishing something here, hope it will work !</p>
  
  <p>I'm trying to create a custom report in Odoo 11, in a custom module I did, I've followed the data I could gather but I can't get past the following problem.</p>
  
  <ul>
  <li>So I created the Report like this :</li>
  </ul>
  
  <blockquote>
  <pre><code>      &lt;report 
            id="production_order_report2"
            model="pb.orders.products"
            string="Production Order (English)"
            report_type="qweb-pdf"
            name="probespoketest.production_order_report_en2_template"
            file="probespoketest.production_order_report_en2_template"
            attachment_use="False"
        /&gt;
  </code></pre>
  </blockquote>
  
  <ul>
  <li>My Qweb report is :</li>
  </ul>
  
  <blockquote>
  <pre><code>  &lt;template id="production_order_report_en2_template"&gt;
     &lt;t t-call="web.html_container"&gt;
          &lt;t t-foreach="docs" t-as="o"&gt;
              &lt;t t-call="web.internal_layout"&gt;
                  &lt;div class="page"&gt;
                      &lt;h2&gt;Report title&lt;/h2&gt;
                      &lt;p&gt;This object's name is&lt;/p&gt;
                    &lt;t t-esc="testing()"/&gt;
                  &lt;/div&gt;
              &lt;/t&gt;
          &lt;/t&gt;
      &lt;/t&gt;
        &lt;/template&gt;
  </code></pre>
  </blockquote>
  
  <ul>
  <li>My python code is :</li>
  </ul>
  
  <blockquote>
  <pre><code>from odoo import api, fields, models, _
  
  class OrderProductsFunctions(models.AbstractModel):
      _name = 'report.probespoketest.production_order_report_en2_template'
  
      def _testing(self):
        result = 0
          return result
  </code></pre>
  </blockquote>
  
  <ul>
  <li>My error is :</li>
  </ul>
  
  <blockquote>
  <pre><code> Odoo Server Error
      Traceback (most recent call last):
        File "/opt/odoo/odoo11/odoo/addons/base/ir/ir_qweb/qweb.py", line 342, in _compiled_fn
          return compiled(self, append, new, options, log)
        File "&lt;template&gt;", line 1, in template_1454_24554
        File "&lt;template&gt;", line 2, in body_call_content_24553
        File "&lt;template&gt;", line 3, in foreach_24552
        File "&lt;template&gt;", line 4, in body_call_content_24551
      TypeError: 'NoneType' object is not callable
  
      During handling of the above exception, another exception occurred:
  
      Traceback (most recent call last):
        File "/opt/odoo/odoo11/addons/web/controllers/main.py", line 1617, in report_download
          response = self.report_routes(reportname, docids=docids, converter='pdf')
        File "/opt/odoo/odoo11/odoo/http.py", line 516, in response_wrap
          def response_wrap(*args, **kw):
        File "/opt/odoo/odoo11/addons/web/controllers/main.py", line 1566, in report_routes
          pdf = report.with_context(context).render_qweb_pdf(docids, data=data)[0]
        File "/opt/odoo/odoo11/odoo/addons/base/ir/ir_actions_report.py", line 628,
  </code></pre>
    
    <p>in render_qweb_pdf
                html = self.with_context(context).render_qweb_html(res_ids, data=data)[0]
              File "/opt/odoo/odoo11/odoo/addons/base/ir/ir_actions_report.py", line 666,
    in render_qweb_html
                return self.render_template(self.report_name, data), 'html'
              File "/opt/odoo/odoo11/odoo/addons/base/ir/ir_actions_report.py", line 470,
    in render_template
                return view_obj.render_template(template, values)
              File "/opt/odoo/odoo11/odoo/addons/base/ir/ir_ui_view.py", line 1195, in render_template
                return self.browse(self.get_view_id(template)).render(values, engine)
              File "/opt/odoo/odoo11/addons/web_editor/models/ir_ui_view.py", line 27, in
    render
                return super(IrUiView, self).render(values=values, engine=engine)
              File "/opt/odoo/odoo11/odoo/addons/base/ir/ir_ui_view.py", line 1204, in render
                return self.env[engine].render(self.id, qcontext)
              File "/opt/odoo/odoo11/odoo/addons/base/ir/ir_qweb/ir_qweb.py", line 57, in
    render
                return super(IrQWeb, self).render(id_or_xml_id, values=values, **context)
              File "/opt/odoo/odoo11/odoo/addons/base/ir/ir_qweb/qweb.py", line 271, in render
                self.compile(template, options)(self, body.append, values or {})
              File "/opt/odoo/odoo11/odoo/addons/base/ir/ir_qweb/qweb.py", line 349, in _compiled_fn
                raise QWebException("Error to render compiling AST", e, path, node and etree.tostring(node[0], encoding='unicode'), name)
            odoo.addons.base.ir.ir_qweb.qweb.QWebException: 'NoneType' object is not callable
            Traceback (most recent call last):
              File "/opt/odoo/odoo11/odoo/addons/base/ir/ir_qweb/qweb.py", line 342, in _compiled_fn
                return compiled(self, append, new, options, log)
              File "", line 1, in template_1454_24554
              File "", line 2, in body_call_content_24553
              File "", line 3, in foreach_24552
              File "", line 4, in body_call_content_24551
            TypeError: 'NoneType' object is not callable</p>
  
  <pre><code>    Error to render compiling AST
      TypeError: 'NoneType' object is not callable
      Template: 1454
      Path: /templates/t/t/t/t/div/t
      Node: &lt;t t-esc="testing()"/&gt;
  </code></pre>
  </blockquote>
  
  <p><strong>manifest</strong>.py and the two <strong>init</strong>.py should be ok but I can provide the code if needed.</p>
  
  <p>Maybe the problem is that I should call the method testing() adding something. If I try to do : </p>
  
  <pre><code>&gt; &lt;t t-esc="docs.testing()"/&gt;
  </code></pre>
  
  <p>Then I get : </p>
  
  <pre><code>&gt; Error to render compiling AST AttributeError: 'pb.orders.products' object has no attribute 'testing' Template: 1454 Path:
  &gt; /templates/t/t/t/t/div/t Node: &lt;t t-esc="docs.testing()"/&gt;
  </code></pre>
  
  <p>Because my testing method is stored in another module that depends on the one I try to modify. But I don't know how to resolve this...</p>
  
  <p><strong>=== EDIT ===</strong></p>
  
  <p>@WaKo</p>
  
  <p>Following your answer I coded this in my models.py (in the module where pb.orders.products is coded, aka "probespokeq") :</p>
  
  <pre><code>class OrderProductsFunctions(models.AbstractModel):
      _name = 'report.probespokeq.production_order_report_en2_template'
  def _testing(self):
      result = 0
      return result
  
  @api.model
  def render_html(self, docids, data=None):
      report_obj = self.env['report']
      report = report_obj._get_report_from_name('probespokeq.production_order_report_en2_template')
      docargs = {
          'doc_ids': docids,
          'doc_model': report.pb.orders.products,
          'docs': self,
          'testing': self._testing,  # You need to add this line
      }
      return report_obj.render('probespokeq.production_order_report_en2_template', docargs)
  </code></pre>
  
  <p>Yet, I still have the same error message. Any idea ? </p>
  
  <p><strong>===== EDIT 2 ====</strong></p>
  
  <p>So, now I changed my class according to @WaKo suggestion with <code>get_report_values</code> instead of <code>render_html</code> so it looks like this :</p>
  
  <blockquote>
  <pre><code>class OrderProductsFunctions(models.AbstractModel):
      _name = 'report.probespokeq.production_order_report_en2_template'
  
      def _testing(self):
          result = 0
          return result
  
      @api.multi
    def get_report_values(self, docids, data=None):
        docs = self.env['pb.orders.products'].browse(docids)
        return {
            'doc_ids': docs.ids,
            'doc_model': 'pb.orders.products',
            'docs': docs,
            'testing': self._testing,  # You need to add this line
        }
  </code></pre>
  </blockquote>
  
  <p>So, now I change my xml as follows : </p>
  
  <pre><code>&gt; &lt;?xml version="1.0"?&gt; &lt;t
  &gt; t-name="probespokeq.production_order_report_en2_template"&gt;    &lt;t
  &gt; t-call="web.html_container"&gt;
  &gt;         &lt;t t-foreach="docs" t-as="o"&gt;
  &gt;             &lt;t t-call="web.internal_layout"&gt;
  &gt;                 &lt;div class="page"&gt;
  &gt;                     &lt;h2&gt;Report title&lt;/h2&gt;
  &gt;                     &lt;p&gt;This object's name is probespokeq&lt;/p&gt;
  &gt;                   &lt;t t-esc="o.testing()"/&gt;
  &gt;                 &lt;/div&gt;
  &gt;             &lt;/t&gt;
  &gt;         &lt;/t&gt;
  &gt;     &lt;/t&gt;      &lt;/t&gt;
  </code></pre>
  
  <p>And I get : </p>
  
  <pre><code>&gt; Error to render compiling AST AttributeError: 'pb.orders.products'
  &gt; object has no attribute 'testing' Template: 1455 Path:
  &gt; /templates/t/t/t/t/div/t Node:  &lt;t t-esc="o.testing()"/&gt;
  </code></pre>