[IMP] models: add generic method toggle_active to inverse the field active
This commit is contained in:
@@ -572,11 +572,6 @@ class res_users(osv.osv):
|
||||
def _is_admin(self):
|
||||
return self.id == openerp.SUPERUSER_ID or self.sudo(self).has_group('base.group_erp_manager')
|
||||
|
||||
@api.multi
|
||||
def toggle_active(self):
|
||||
for user in self:
|
||||
user.active = not user.active
|
||||
|
||||
def get_company_currency_id(self, cr, uid, context=None):
|
||||
return self.browse(cr, uid, uid, context=context).company_id.currency_id.id
|
||||
|
||||
|
||||
@@ -5204,6 +5204,12 @@ class BaseModel(object):
|
||||
index = dict((r['id'], r) for r in result)
|
||||
return [index[x] for x in record_ids if x in index]
|
||||
|
||||
@api.multi
|
||||
def toggle_active(self):
|
||||
""" Inverse the value of the field ``active`` on the records in ``self``. """
|
||||
for record in self:
|
||||
record.active = not record.active
|
||||
|
||||
def _register_hook(self, cr):
|
||||
""" stuff to do right after the registry is built """
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user