mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[ADD] add module 'web_warning_on_save'
This commit is contained in:
39
web_warning_on_save/controller.py
Normal file
39
web_warning_on_save/controller.py
Normal file
@@ -0,0 +1,39 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Author: Damien Crier
|
||||
# Copyright 2015 Camptocamp SA
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import openerp
|
||||
|
||||
|
||||
class WarningOnSaveController(openerp.addons.web.http.Controller):
|
||||
_cp_path = "/web/warning_on_save"
|
||||
|
||||
@openerp.addons.web.http.jsonrequest
|
||||
def check_warning_on_save(self, req, model, id):
|
||||
"""
|
||||
try to call a method on the model given in parameter
|
||||
if method does not exist in the model, do nothing
|
||||
"""
|
||||
m = req.session.model(model)
|
||||
try:
|
||||
return getattr(m, 'check_warning_on_save')(id, req.context)
|
||||
|
||||
except:
|
||||
return False
|
||||
Reference in New Issue
Block a user