[REF] allow to intercept the signals sent to workflows (through buttons) in objects. This is done by adding a function named _workflow_signal() in orm that can be inherited in dedicated objects. Courtesy from Olivier Dony

bzr revid: qdp-launchpad@openerp.com-20120918130436-ll7potrsya23lc36
This commit is contained in:
Odowan Kenobi 2012-09-18 15:04:36 +02:00 committed by Quentin (OpenERP)
parent 09ab484e0b
commit 4b896c36af
2 changed files with 13 additions and 5 deletions

View File

@ -3792,6 +3792,12 @@ class BaseModel(object):
for res_id in ids:
getattr(wf_service, trigger)(uid, self._name, res_id, cr)
def _workflow_signal(self, cr, uid, ids, signal, context=None):
"""Send given workflow signal"""
wf_service = netsvc.LocalService("workflow")
for res_id in ids:
wf_service.trg_validate(uid, self._name, res_id, signal, cr)
def unlink(self, cr, uid, ids, context=None):
"""
Delete records with given ids

View File

@ -184,16 +184,18 @@ class object_proxy(object):
cr.close()
return res
def exec_workflow_cr(self, cr, uid, obj, method, *args):
wf_service = netsvc.LocalService("workflow")
return wf_service.trg_validate(uid, obj, args[0], method, cr)
def exec_workflow_cr(self, cr, uid, obj, signal, *args):
object = pooler.get_pool(cr.dbname).get(obj)
if not object:
raise except_osv('Object Error', 'Object %s doesn\'t exist' % str(obj))
return object._workflow_signal(cr, uid, [args[0]], signal)
@check
def exec_workflow(self, db, uid, obj, method, *args):
def exec_workflow(self, db, uid, obj, signal, *args):
cr = pooler.get_db(db).cursor()
try:
try:
res = self.exec_workflow_cr(cr, uid, obj, method, *args)
res = self.exec_workflow_cr(cr, uid, obj, signal, *args)
cr.commit()
except Exception:
cr.rollback()