diff --git a/trytond/ir/translation.xml b/trytond/ir/translation.xml
index 8ad18e5222..9a95fd10ba 100644
--- a/trytond/ir/translation.xml
+++ b/trytond/ir/translation.xml
@@ -124,6 +124,15 @@ this repository contains the full copyright notices and license terms. -->
ir
+
+ size_validation_record
+ en_US
+ error
+ The field "%s" on "%s" is too long.
+ The field "%s" on "%s" is too long.
+ ir
+
+
access_error
en_US
diff --git a/trytond/model/browse.py b/trytond/model/browse.py
index 59af073f81..91f12b0e16 100644
--- a/trytond/model/browse.py
+++ b/trytond/model/browse.py
@@ -132,7 +132,8 @@ class BrowseRecord(object):
elif hasattr(j, 'get_target'):
model = j.get_target(self._model.pool)
if j._type in ('many2one',):
- if not data[i]:
+ if not data[i] and not (isinstance(data[i], (int, long))
+ and not isinstance(data[i], type(False))):
data[i] = BrowseRecordNull()
else:
ctx = self._context
@@ -184,7 +185,7 @@ class BrowseRecord(object):
return hash((self._model_name, self._id))
def __nonzero__(self):
- return bool(self._id)
+ return True
__repr__ = __str__
diff --git a/trytond/model/modelstorage.py b/trytond/model/modelstorage.py
index b61debb349..80d37af688 100644
--- a/trytond/model/modelstorage.py
+++ b/trytond/model/modelstorage.py
@@ -950,6 +950,25 @@ class ModelStorage(Model):
error_args=self._get_error_args(cursor,
user, field_name, context=context),
context=context)
+ # validate required
+ if field.required:
+ for record in records:
+ if isinstance(record[field_name], (BrowseRecordNull,
+ type(None), type(False))) and not record[field_name]:
+ self.raise_user_error(cursor,
+ 'required_validation_record',
+ error_args=self._get_error_args(cursor,
+ user, field_name, context=context),
+ context=context)
+ # validate size
+ if hasattr(field, 'size') and field.size:
+ for record in records:
+ if len(record[field_name]) > field.size:
+ self.raise_user_error(cursor,
+ 'size_validation_record',
+ error_args=self._get_error_args(cursor,
+ user, field_name, context=context),
+ context=context)
def _clean_defaults(self, defaults):
vals = {}