← Back to team overview

openerp-expert-framework team mailing list archive

Re: Web addons controller and static folders

 

Hi,

FYI the conversation on this problem went on on stackoverflow and the problem is fixed now, thanks to Xavier's help:

http://stackoverflow.com/questions/8817467/openerp-web-client-6-1-how-to-override-base-javascript-functions

Cheers


On 01/11/2012 11:50 AM, Xavier Morel wrote:
On 2012-01-11, at 11:14 , Simone Orsi wrote:
And, if you are looking for a way to override JS functions... so am I :)

See: http://stackoverflow.com/questions/8817467/openerp-web-client-6-1-how-to-override-base-javascript-functions
That's a bit of a special issue since you want to alter the prototype (the class, if you will) of an object which is already instantiated (a WebClient instance is the root of the system, so it's probably already there by the time your code is loaded).

In that case, you can't replace the class with a subclass, you have to re-open the class (in a manner similar to Ruby), for that there is an `include` method on class objects:

     openerp.mytest = function(openerp) {
         openerp.web.WebClient.include({
             on_logout: function() {
                 alert('mine');
                 this._super.apply(this, arguments);
             }
         });
     }

(as in Ruby, `this._super` is bound to the method you're replacing, if any, for in-place class alterations)

If you check the view_list_editable.js implementation file, it provides examples of that since it needs to reopen and alter the listview's code in order to add editability.




References