title: How to refresh a view after data is received in Odoo 11/12
body: <p>Is there a better way to do this? </p>
  
  <p>In my view I added this to the record view.xml:</p>
  
  <pre><code>&lt;field name="arch" type="xml"&gt;
    &lt;tree string="Test View" js_class="test_view"&gt;
      &lt;field name="testField" /&gt;
    &lt;/tree&gt;
  &lt;/field&gt;
  </code></pre>
  
  <p>I have a template file template.xml that I referenced the <strong>manifest.py</strong></p>
  
  <pre><code>&lt;xpath&gt;
    &lt;script type="text/javascript" src="/&lt;mymodule&gt;/static/src/js/&lt;mymodule&gt;.js"&gt; 
    &lt;/script&gt;
  &lt;/xpath&gt;
  </code></pre>
  
  <p>Added this function to my model:</p>
  
  <pre><code>@api.model
  def generate_data(self):
    # do stuff on database
    pass
  </code></pre>
  
  <p>I have this in my module controller:</p>
  
  <pre><code>class Reports(http.Controller):
      @http.route('/test/refresh', type='json', auth="user")
      def refresh(self):
          return request.env['model.name'].generate_data()
  </code></pre>
  
  <p>I then extended the base ListView in the above mentioned .js:</p>
  
  <pre><code>odoo.define('&lt;mymodule&gt;.updateview, function (require) {
  
    var view_registery = require('web.view_registry');
    var ListController = require('web.ListController');
    var ListView = require('web.ListView');
  
    var TestListController = ListController.extend({
      init: function () {
        this._super.apply(this, arguments);
              var self = this;
              this._rpc({
                  route: '/test/refresh'
              }).then(function() {
                  self.reload();
              });
  
      }
    });
  
  
    var ReportListView = ListView.extend({
        config: _.extend({}, ListView.prototype.config, {
            Controller: TestListController 
         }),
     });
    view_registery.add('test_view')
  });
  </code></pre>
  
  <p>It all works well on loading the page. Is there a better way that Odoo recommends? Or maybe this can help someone else.</p>