Commit e0725ff1 authored by Ayush Tiwari's avatar Ayush Tiwari

bt5_config: Raise error in case object is not found. Also, no need to resolve path again

parent 8d9048b5
...@@ -624,38 +624,27 @@ class BusinessItem(XMLObject): ...@@ -624,38 +624,27 @@ class BusinessItem(XMLObject):
p = context.getPortalObject() p = context.getPortalObject()
path = self.getProperty('item_path') path = self.getProperty('item_path')
try: obj = p.unrestrictedTraverse(path)
# XXX: After we apply _resolve path list while storing Data for the obj = obj._getCopy(context)
# Business Manager, this should be of no use as there will be no path
# where we are going to achieve something different for relative_path # We should remove the extra properties of object so that there
# from the result of _resolvePath on a given path. # shouldn't be redundancy of the proeprties
# TODO: Remove this after checking successfull implementation of removable_property_list = kw.get('removable_property_list')
# _resolve path in Business Manager in storeTemplateData
for relative_url in self._resolvePath(p, [], path.split('/')): # We should also add extra parameter to remove sub-objects by removing
obj = p.unrestrictedTraverse(relative_url) # `_tree` for any erp5 object. This way we can have control over adding
obj = obj._getCopy(context) # sub-objects as new Business Item objects
remove_sub_objects = kw.get('remove_sub_objects')
# We should remove the extra properties of object so that there if remove_sub_objects:
# shouldn't be redundancy of the proeprties removable_property_list.append('_tree')
removable_property_list = kw.get('removable_property_list') obj = self.removeProperties(obj, 1, properties=removable_property_list)
obj = obj.__of__(context)
# We should also add extra parameter to remove sub-objects by removing # XXX: '_recursiveRemoveUid' is not working as expected
# `_tree` for any erp5 object. This way we can have control over adding _recursiveRemoveUid(obj)
# sub-objects as new Business Item objects obj = aq_base(obj)
remove_sub_objects = kw.get('remove_sub_objects') obj.isIndexable = ConstantGetter('isIndexable', value=False)
if remove_sub_objects: new_id = self.generateNewId()
removable_property_list.append('_tree') self._setObject(new_id, obj, suppress_events=True)
obj = self.removeProperties(obj, 1, properties=removable_property_list)
obj = obj.__of__(context)
# XXX: '_recursiveRemoveUid' is not working as expected
_recursiveRemoveUid(obj)
obj = aq_base(obj)
obj.isIndexable = ConstantGetter('isIndexable', value=False)
new_id = self.generateNewId()
self._setObject(new_id, obj, suppress_events=True)
except AttributeError:
# In case the object doesn't exist, just pass without raising error
pass
def _resolvePath(self, folder, relative_url_list, id_list): def _resolvePath(self, folder, relative_url_list, id_list):
""" """
......
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