[FIX] fields.reference: don't accept half-defined references - second part of fix, in create()

lp bug: https://launchpad.net/bugs/604604 fixed

bzr revid: odo@openerp.com-20101220162501-v0xag7nwdhfij14f
This commit is contained in:
Olivier Dony
2010-12-20 17:25:01 +01:00
parent afed2d47fe
commit 0fedbb3215
+1 -15
View File
@@ -3739,21 +3739,7 @@ class orm(orm_template):
if field in self._columns \
and hasattr(self._columns[field], 'selection') \
and vals[field]:
if self._columns[field]._type == 'reference':
val = vals[field].split(',')[0]
else:
val = vals[field]
if isinstance(self._columns[field].selection, (tuple, list)):
if val not in dict(self._columns[field].selection):
raise except_orm(_('ValidateError'),
_('The value "%s" for the field "%s" is not in the selection') \
% (vals[field], field))
else:
if val not in dict(self._columns[field].selection(
self, cr, user, context=context)):
raise except_orm(_('ValidateError'),
_('The value "%s" for the field "%s" is not in the selection') \
% (vals[field], field))
self._check_selection_field_value(cr, user, field, vals[field], context=context)
if self._log_access:
upd0 += ',create_uid,create_date'
upd1 += ',%s,now()'