Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
5215 Ansichten

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
Verwerfen

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

Beste Antwort

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
Verwerfen
Autor

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)?

Autor

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

Verknüpfte Beiträge Antworten Ansichten Aktivität
1
März 24
8832
3
Mai 20
6896
2
Nov. 15
8115
0
März 25
1261
0
Jan. 25
3302