ORM: Better message when copying non-existing records

by: jvo@openerp.com

In both cases, we end up with an exception. But it is better to know
which model+id has failed.

bzr revid: p_christ@hol.gr-20101116150047-xtyz8nrt6465ug2k
This commit is contained in:
P. Christeas 2010-11-16 17:00:47 +02:00
parent 63d562de39
commit 4187facd9f
1 changed files with 5 additions and 1 deletions

View File

@ -4099,7 +4099,11 @@ class orm(orm_template):
context_wo_lang = context.copy()
if 'lang' in context:
del context_wo_lang['lang']
data = self.read(cr, uid, [id], context=context_wo_lang)[0]
data = self.read(cr, uid, [id,], context=context_wo_lang)
if data:
data = data[0]
else:
raise IndexError( _("Record #%d of %s not found, cannot copy!") %( id, self._name))
fields = self.fields_get(cr, uid, context=context)
for f in fields: