Commit ee1029ed authored by Jean-Paul Smets's avatar Jean-Paul Smets

Implementation of relation setters


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1160 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cf6fea4a
...@@ -25,15 +25,28 @@ if request.has_key('previous_form_id'): ...@@ -25,15 +25,28 @@ if request.has_key('previous_form_id'):
form = getattr(context, form_id) form = getattr(context, form_id)
field = form.get_field(field_id) field = form.get_field(field_id)
base_category = field.get_value('base_category') base_category = field.get_value('base_category')
relation_setter_id = field.get_value('relation_setter_id')
if relation_setter_id: relation_setter = getattr(o, relation_setter_id)
portal_type = map(lambda x:x[0],field.get_value('portal_type')) portal_type = map(lambda x:x[0],field.get_value('portal_type'))
if uids != []: if uids != []:
if relation_setter_id:
# Clear the relation
relation_setter((), portal_type=portal_type)
# Warning, portal type is at strange value because of form
# And update it
relation_setter(uids, portal_type=portal_type)
else:
# Clear the relation # Clear the relation
o.setValueUids(base_category, (), portal_type=portal_type) o.setValueUids(base_category, (), portal_type=portal_type)
# Warning, portal type is at strange value because of form # Warning, portal type is at strange value because of form
# And update it # And update it
o.setValueUids(base_category, uids, portal_type=portal_type) o.setValueUids(base_category, uids, portal_type=portal_type)
else: else:
if relation_setter_id:
# Clear the relation
relation_setter((), portal_type=portal_type)
else:
# Clear the relation # Clear the relation
o.setValueUids(base_category, (), portal_type=portal_type) o.setValueUids(base_category, (), portal_type=portal_type)
......
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