This question has been flagged
2 Replies
12538 Views

I try to call a JS function from my qweb inherited template via:

 <tr t-extend="ListView.row">
      <t t-jquery="td" t-operation="replace">
     [...]
      <t t-set="test" t-value="value_check(column.id, record.get(column.id))"/>

But I allways get the Error:

   Error: QWeb2 - template['ListView.rows']: 
   Runtime Error: Error: QWeb2 - template['ListView.row']: 
   Runtime Error: TypeError: dict.value_check is not a function

without the function call the extended template works fine. So the JS function cannot be found. First I tried this JS code for my function:

openerp.my_module = function(instance){
  var module = instance.web // loading the namespace of the 'sample' module

  module.View.include({
      value_check: function(key, value){
          console.log(key + ": " + value);
          return true;
      },        
  });
};

and then also

openerp.my_module = function(instance){
  var module = instance.web; // loading the namespace of the 'sample' module

  var _super_ = module.View.prototype.value_check;

  module.View.prototype.value_check = function(key, value){
       console.log(key +': '+value);
       _super_.call(this);
      return true;
  };
};

any suggestions? Could it be its because of the inherited tempate? But I can call stuff like render_cell from the web module js. It even doesn't work if I put the check_value into the view_list.js of the web module.

Avatar
Discard
Author Best Answer

OK, I solved it: The class I was extending was wrong.

openerp.my_module = function(instance){
    var module = instance.web.list  // loading the namespace of  'web.list' 

    module.Column.include({         // include to  'web.list.Column' class
        value_check: function(key, value){
           console.log(key + ": " + value);
           return true;
        },        
    });
};

Then I have to call my function via:

  <t t-set="test" t-value="column.value_check(column.id, record.get(column.id))"/>

...and it works perfectly.

Avatar
Discard
Best Answer

Is "custom_list" the name of your module folder? That would prevent the JS from loading. Either rename the module or edit the JS to say "openerp.web_module_name".

Avatar
Discard
Author

yes it is the module name, but it doesn't work. I edited my post so its not confusing, I hope. I even tried to add the function to the web module itself but still the same error. Could it be because I extended the ListView.row template?

Author

thx ... u put me on the right track