Show an error and raise an exception if the _name is not present in an object

bzr revid: stephane@tinyerp.com-20081017224112-7sr2ihk7l7wuc2hg
This commit is contained in:
Stephane Wirtel 2008-10-18 00:41:12 +02:00
parent d1c0029e72
commit f2644d5bc2
1 changed files with 8 additions and 0 deletions

View File

@ -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: