[IMP] orm: expose a signal_xxx() method to call workflow.trg_validate().

bzr revid: vmt@openerp.com-20130125155132-nhyntobe5xm1g7h0
This commit is contained in:
Vo Minh Thu 2013-01-25 16:51:32 +01:00
parent 8eb9987b0e
commit ad7d846106
1 changed files with 14 additions and 0 deletions

View File

@ -5251,6 +5251,20 @@ class BaseModel(object):
""" stuff to do right after the registry is built """
pass
def __getattr__(self, name):
if name.startswith('signal_'):
signal_name = name[len('signal_'):]
assert signal_name
def handle_workflow_signal(cr, uid, ids):
workflow_service = netsvc.LocalService("workflow")
res = {}
for id in ids:
# TODO consolidate trg_validate() and the functions it calls to work on a list of IDs.
res[id] = workflow_service.trg_validate(uid, self._name, id, signal_name, cr)
return res
return handle_workflow_signal
raise AttributeError
# keep this import here, at top it will cause dependency cycle errors
import expression