From f2644d5bc2fbde9d9282eb647283e26c91e2ce43 Mon Sep 17 00:00:00 2001 From: Stephane Wirtel Date: Sat, 18 Oct 2008 00:41:12 +0200 Subject: [PATCH] Show an error and raise an exception if the _name is not present in an object bzr revid: stephane@tinyerp.com-20081017224112-7sr2ihk7l7wuc2hg --- bin/osv/orm.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 252fa3380be..a5c390d3cde 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -367,6 +367,14 @@ class orm_template(object): self._field_create(cr, context) def __init__(self, cr): + if not self._name and not hasattr(self, '_inherit'): + name = type(self).__name__.split('.')[0] + msg = "The class %s has to have a _name attribute" % name + + logger = netsvc.Logger() + logger.notifyChannel('orm', netsvc.LOG_ERROR, msg ) + raise except_orm('ValueError', msg ) + if not self._description: self._description = self._name if not self._table: