Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
5205 Visualizzazioni

I was able to reach this point, my NEW.js script file is loaded in /web/database/manager page.

If I create a break point in "var break_point;" it stops there.

I don't get any error, but it just don't execute the rest of the code...

openerp.MYMODULE = function (instance) {
/*just for test in a break point*/
var break_point;
/* redefine from chrome.js:412 */
instance.web.DatabaseManagerNEW = instance.web.DatabaseManager.extend( {
do_render: function() {
this._super(parent);
/* add new submit handler*/
self.$el.find("form[name=NEW_db_form]").validate({ submitHandler: self.do_NEW });
},
do_NEW: function(form) {
var self = this;
var $form = $(form),
fields = $form.serializeArray();
self.rpc("/web/database/NEW", {'fields': fields}).done(function(result) {
if (result.error) {
self.display_error(result);
return;
}
self.start();
});
},
});
/* redefine view_form.js:72 */
instance.web.FormViewNEW = instance.web.FormView.extend({
load_form: function(data) {
this._super(parent);
/* redefine button */
if (!this.sidebar && this.options.$sidebar) {
this.sidebar.add_items('other', _.compact([
self.is_action_enabled('create') && { label: _t('NEW'), callback: self.on_button_NEW }
]));
}
},
on_button_NEW: function() {
var self = this;
return this.has_been_loaded.then(function() {
return self.dataset.call('copy', [self.datarecord.id, {}, self.dataset.context]).then(function(new_id) {
self.record_created(new_id);
self.to_edit_mode();
});
});
},
});
};

This code inserted in those files works, but not in my NEW.js file.

Avatar
Abbandona

Hi Carlos,
how and when you need to use that new widgets that you are creating?. Note that when you use extend you are creating a new widget and normally you need to use it with a qweb client template and/or use it through a client action or a new kind of view. What is the need for those new widgets?. I think that the reason that your code is not working relies in that questions.
Provide more info about what you need to do to be able to help you. I you just wanna change the behavior of the original widget you need to use 'include' not 'extend'. The difference is that include change the widget in place and extend return a copy of the widget with the changes

Risposta migliore

Hello,

you have to return super by method like this :

instance.web.DatabaseManagerNEW = instance.web.DatabaseManager.extend( {
     do_render: function() {
         /* add new submit handler*/
         self.$el.find("form[name=NEW_db_form]").validate({ submitHandler: self.do_NEW });
         return this._super();
    }, do_NEW: function(form) { var self = this; var $form = $(form), fields = $form.serializeArray(); self.rpc("/web/database/NEW", {'fields': fields}).done(function(result) { if (result.error) { self.display_error(result); return; } self.start(); });
         return this._super(form); }, })


Hope this will help you!!

Avatar
Abbandona
Autore

not working, I've even relpaced all "self" by "this". could it be new entities names? should be equal? or change the function names (ex:. do_render to do_render_new)?

Autore

thanks, it was some js errors, ubt that _super() helped a lot

Post correlati Risposte Visualizzazioni Attività
1
mar 24
8819
3
mag 20
6892
2
nov 15
8105
0
mar 25
1247
0
gen 25
3286