[IMP] models: add generic method toggle_active to inverse the field active

This commit is contained in:
Raphael Collet
2015-08-31 12:07:41 +02:00
parent 80e5b4245a
commit a38b79a30f
2 changed files with 6 additions and 5 deletions
-5
View File
@@ -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
+6
View File
@@ -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