Browse Source

[FIX] keep _register_hook's signature and call super

pull/352/head
Stefan Rijnhart 9 years ago
committed by eLBati
parent
commit
6a28aa2843
  1. 12
      base_optional_quick_create/model.py

12
base_optional_quick_create/model.py

@ -37,9 +37,7 @@ class ir_model(orm.Model):
_("Can't create quickly. Opening create form"))
return wrapper
def _register_hook(self, cr, ids=None):
if ids is None:
ids = self.search(cr, SUPERUSER_ID, [])
def _patch_quick_create(self, cr, ids):
for model in self.browse(cr, SUPERUSER_ID, ids):
if model.avoid_quick_create:
model_name = model.model
@ -50,14 +48,18 @@ class ir_model(orm.Model):
model_obj.check_quick_create = True
return True
def _register_hook(self, cr):
self._patch_quick_create(cr, self.search(cr, SUPERUSER_ID, []))
return super(ir_model, self)._register_hook(cr)
def create(self, cr, uid, vals, context=None):
res_id = super(ir_model, self).create(cr, uid, vals, context=context)
self._register_hook(cr, [res_id])
self._patch_quick_create(cr, [res_id])
return res_id
def write(self, cr, uid, ids, vals, context=None):
if isinstance(ids, (int, long)):
ids = [ids]
res = super(ir_model, self).write(cr, uid, ids, vals, context=context)
self._register_hook(cr, ids)
self._patch_quick_create(cr, ids)
return res
Loading…
Cancel
Save