[FIX] rename controller

[IMP] launch openerp.web.Dialog instead of an alert()
This commit is contained in:
Damien Crier
2015-06-08 10:58:59 +02:00
parent a5dfee75b6
commit 239cc13fff
3 changed files with 27 additions and 22 deletions

View File

@@ -1,23 +1,28 @@
openerp.web_warning_on_save = function (instance) {
instance.web.FormView.include({
on_button_save: function(e) {
instance.web.FormView.include({
on_button_save: function(e) {
// inherit method to be able to display an alert if
// method called returns a string
var id = 0;
var self = this;
self._super.apply(this, arguments).done(function(id){
var model = self.model;
var param = {'model': model,
'id': self.datarecord.id ? self.datarecord.id : id};
self.rpc('/web/warning_on_save/check_warning_on_save', param)
.done(function(res) {
if (res != false){
alert(res);
}
});
})
},
});
var self = this;
return self._super.apply(this, arguments).done(function(id){
var model = self.model;
var param = {
'model': model,
'id': self.datarecord.id ? self.datarecord.id : id
};
self.rpc('/web_warning_on_save/check_warning_on_save', param)
.done(function(res) {
if (res != false){
var dialog = new instance.web.Dialog(this, {
title: _t("Warning"),
width: 850,
}).open();
dialog.$el.html(res);
}
});
})
},
});
};