[ADD] add module 'web_warning_on_save'

This commit is contained in:
Damien Crier
2015-06-05 07:53:38 +02:00
parent 506f2cc49d
commit 392f0ef14a
5 changed files with 215 additions and 0 deletions

View 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