[MERGE] ir_ui_view: better constraints on `arch` and `model`.
bzr revid: vmt@openerp.com-20130605132332-s0azrlqk0hjvders
This commit is contained in:
commit
fd61bfac43
|
@ -122,11 +122,12 @@ class view(osv.osv):
|
|||
@return: the rendered definition (arch) of the view, always utf-8 bytestring (legacy convention)
|
||||
if no error occurred, else False.
|
||||
"""
|
||||
if view.model not in self.pool:
|
||||
return False
|
||||
try:
|
||||
fvg = self.pool[view.model].fields_view_get(cr, uid, view_id=view.id, view_type=view.type, context=context)
|
||||
return fvg['arch']
|
||||
except:
|
||||
_logger.exception("Can't render view %s for model: %s", view.xml_id, view.model)
|
||||
return False
|
||||
|
||||
def _check_xml(self, cr, uid, ids, context=None):
|
||||
|
@ -152,8 +153,15 @@ class view(osv.osv):
|
|||
return False
|
||||
return True
|
||||
|
||||
def _check_model(self, cr, uid, ids, context=None):
|
||||
for view in self.browse(cr, uid, ids, context):
|
||||
if view.model not in self.pool:
|
||||
return False
|
||||
return True
|
||||
|
||||
_constraints = [
|
||||
(_check_xml, 'Invalid XML for View Architecture!', ['arch'])
|
||||
(_check_model, 'The model name does not exist.', ['model']),
|
||||
(_check_xml, 'The model name does not exist or the view architecture cannot be rendered.', ['arch', 'model']),
|
||||
]
|
||||
|
||||
def _auto_init(self, cr, context=None):
|
||||
|
|
|
@ -1539,7 +1539,7 @@ class BaseModel(object):
|
|||
else:
|
||||
translated_msg = trans._get_source(cr, uid, self._name, 'constraint', lng, msg)
|
||||
error_msgs.append(
|
||||
_("Error occurred while validating the field(s) %s: %s") % (','.join(fields), translated_msg)
|
||||
_("The field(s) `%s` failed against a constraint: %s") % (', '.join(fields), translated_msg)
|
||||
)
|
||||
self._invalids.update(fields)
|
||||
if error_msgs:
|
||||
|
|
Loading…
Reference in New Issue