[IMP] orm: all workflow trigger calls in common method for increased flexibility
bzr revid: odo@openerp.com-20120504151327-iib0qtvy3d79xgig
This commit is contained in:
parent
f66db86718
commit
bec50b5df9
|
@ -3697,6 +3697,12 @@ class BaseModel(object):
|
||||||
_('Operation prohibited by access rules, or performed on an already deleted document (Operation: %s, Document type: %s).')
|
_('Operation prohibited by access rules, or performed on an already deleted document (Operation: %s, Document type: %s).')
|
||||||
% (operation, self._description))
|
% (operation, self._description))
|
||||||
|
|
||||||
|
def _workflow_trigger(self, cr, uid, ids, trigger, context=None):
|
||||||
|
"""Call given workflow trigger as a result of a CRUD operation"""
|
||||||
|
wf_service = netsvc.LocalService("workflow")
|
||||||
|
for res_id in ids:
|
||||||
|
getattr(wf_service, trigger)(uid, self._name, res_id, cr)
|
||||||
|
|
||||||
def unlink(self, cr, uid, ids, context=None):
|
def unlink(self, cr, uid, ids, context=None):
|
||||||
"""
|
"""
|
||||||
Delete records with given ids
|
Delete records with given ids
|
||||||
|
@ -3735,10 +3741,7 @@ class BaseModel(object):
|
||||||
property_ids = ir_property.search(cr, uid, [('res_id', 'in', ['%s,%s' % (self._name, i) for i in ids])], context=context)
|
property_ids = ir_property.search(cr, uid, [('res_id', 'in', ['%s,%s' % (self._name, i) for i in ids])], context=context)
|
||||||
ir_property.unlink(cr, uid, property_ids, context=context)
|
ir_property.unlink(cr, uid, property_ids, context=context)
|
||||||
|
|
||||||
wf_service = netsvc.LocalService("workflow")
|
self._workflow_trigger(cr, uid, ids, 'trg_delete', context=context)
|
||||||
for oid in ids:
|
|
||||||
wf_service.trg_delete(uid, self._name, oid, cr)
|
|
||||||
|
|
||||||
|
|
||||||
self.check_access_rule(cr, uid, ids, 'unlink', context=context)
|
self.check_access_rule(cr, uid, ids, 'unlink', context=context)
|
||||||
pool_model_data = self.pool.get('ir.model.data')
|
pool_model_data = self.pool.get('ir.model.data')
|
||||||
|
@ -4039,9 +4042,7 @@ class BaseModel(object):
|
||||||
todo.append(id)
|
todo.append(id)
|
||||||
self.pool.get(object)._store_set_values(cr, user, todo, fields_to_recompute, context)
|
self.pool.get(object)._store_set_values(cr, user, todo, fields_to_recompute, context)
|
||||||
|
|
||||||
wf_service = netsvc.LocalService("workflow")
|
self._workflow_trigger(cr, user, ids, 'trg_write', context=context)
|
||||||
for id in ids:
|
|
||||||
wf_service.trg_write(user, self._name, id, cr)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -4233,8 +4234,7 @@ class BaseModel(object):
|
||||||
self.name_get(cr, user, [id_new], context=context)[0][1] + \
|
self.name_get(cr, user, [id_new], context=context)[0][1] + \
|
||||||
"' " + _("created.")
|
"' " + _("created.")
|
||||||
self.log(cr, user, id_new, message, True, context=context)
|
self.log(cr, user, id_new, message, True, context=context)
|
||||||
wf_service = netsvc.LocalService("workflow")
|
self._workflow_trigger(cr, user, [id_new], 'trg_create', context=context)
|
||||||
wf_service.trg_create(user, self._name, id_new, cr)
|
|
||||||
return id_new
|
return id_new
|
||||||
|
|
||||||
def browse(self, cr, uid, select, context=None, list_class=None, fields_process=None):
|
def browse(self, cr, uid, select, context=None, list_class=None, fields_process=None):
|
||||||
|
|
Loading…
Reference in New Issue