From 4187facd9f033bc4b9e4eda8f81dcc6cc2bb3784 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Tue, 16 Nov 2010 17:00:47 +0200 Subject: [PATCH] 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 --- bin/osv/orm.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index ef2ca8e171a..0d37f5afc15 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -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: