Commit e0d63ab9 authored by Sebastien Robin's avatar Sebastien Robin

- add acquisition wrappers on temp constraint

- fix some typo errors

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43461 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 08c6fddc
...@@ -58,6 +58,9 @@ class AccountTypeConstraint(ConstraintMixin): ...@@ -58,6 +58,9 @@ class AccountTypeConstraint(ConstraintMixin):
def _checkConsistency(self, obj, fixit=0): def _checkConsistency(self, obj, fixit=0):
"""Implement here the consistency checker """Implement here the consistency checker
""" """
# self, the constraint is a temp object without acquisition wrappers, for
# now we need to add acquisition wrappers for category accessors
self_in_context = self.__of__(obj.getPortalObject())
error_list = [] error_list = []
errors = [] errors = []
if getattr(obj, 'getAccountType', _MARKER) is _MARKER: if getattr(obj, 'getAccountType', _MARKER) is _MARKER:
...@@ -65,20 +68,20 @@ class AccountTypeConstraint(ConstraintMixin): ...@@ -65,20 +68,20 @@ class AccountTypeConstraint(ConstraintMixin):
obj, obj,
translateString("Account does not have account_type category"))) translateString("Account does not have account_type category")))
else: else:
constraint_line_list = self.objectValues(sort_on='int_index') constraint_line_list = self_in_context.objectValues(sort_on='int_index')
if len(constraint_line_list) == 0: if len(constraint_line_list) == 0:
raise NotImplementedError( raise NotImplementedError(
"AccountTypeConstraint does not define an account type mapping lines") "AccountTypeConstraint does not define an account type mapping lines")
for constraint_line in constraint_line_list: for constraint_line in constraint_line_list:
gap = constraint_line.getGap() gap = constraint_line.getGap(base=1)
account_type_list = contraint_line.getAccountTypeList() account_type_list = constraint_line.getAccountTypeList()
if obj.isMemberOf(category): if obj.isMemberOf(gap):
if obj.getAccountType() not in account_type_list: if obj.getAccountType() not in account_type_list:
error_list.append(self._generateError(obj, error_list.append(self._generateError(obj,
self._getMessage('message_inconsistent_account_type'), self._getMessage('message_inconsistent_account_type'),
# XXX we should probably print translated logical path of # XXX we should probably print translated logical path of
# categories instead of category path. # categories instead of category path.
mapping=dict(category=category, mapping=dict(category=gap,
account_type_list= account_type_list=
', '.join(account_type_list)))) ', '.join(account_type_list))))
if fixit: if fixit:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment