forked from Techsystech/web
parent
a5dfee75b6
commit
239cc13fff
|
@ -1,8 +1,8 @@
|
|||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||
:alt: License: AGPL-3
|
||||
|
||||
web_warning_on_save
|
||||
===========
|
||||
Raise warning when saving
|
||||
=========================
|
||||
|
||||
This module was written to extend the functionality of saving a record in the web interface.
|
||||
/!\/!\/!\ In no way this module stops the save of the record. You must consider this as a warning displayed
|
||||
|
|
|
@ -23,7 +23,7 @@ import openerp
|
|||
|
||||
|
||||
class WarningOnSaveController(openerp.addons.web.http.Controller):
|
||||
_cp_path = "/web/warning_on_save"
|
||||
_cp_path = "/web_warning_on_save"
|
||||
|
||||
@openerp.addons.web.http.jsonrequest
|
||||
def check_warning_on_save(self, req, model, id):
|
||||
|
@ -32,8 +32,8 @@ class WarningOnSaveController(openerp.addons.web.http.Controller):
|
|||
if method does not exist in the model, do nothing
|
||||
"""
|
||||
m = req.session.model(model)
|
||||
try:
|
||||
if hasattr(m, 'check_warning_on_save'):
|
||||
return getattr(m, 'check_warning_on_save')(id, req.context)
|
||||
|
||||
except:
|
||||
else:
|
||||
return False
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
});
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue