Commit e965b406 authored by Sebastien Robin's avatar Sebastien Robin

make sure that it still works when some objects are arleady there

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15271 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 034bb8f0
...@@ -287,8 +287,17 @@ class BaobabConduit(ERP5Conduit): ...@@ -287,8 +287,17 @@ class BaobabConduit(ERP5Conduit):
parent_object_path = erp5_site_path + path parent_object_path = erp5_site_path + path
try: try:
# Get the object with the path # Get the object with the path
parent_object = object.restrictedTraverse(parent_object_path) parent_object_path_list = parent_object_path.split('/')
root = getattr(object, parent_object_path_list[0])
parent_object = root
for subpath in parent_object_path_list[1:]:
parent_object = getattr(aq_base(parent_object), subpath, None)
if parent_object is None:
break
if parent_object is not None: if parent_object is not None:
# call restrictedTraverse to make sure to get object
# with acquisition, wich is required for creating sub object
parent_object = object.restrictedTraverse(parent_object_path)
break break
except ConflictError: except ConflictError:
raise raise
...@@ -322,10 +331,11 @@ class BaobabConduit(ERP5Conduit): ...@@ -322,10 +331,11 @@ class BaobabConduit(ERP5Conduit):
subobject.setCareerRole('client') subobject.setCareerRole('client')
# We first try to get the organisation corresponding # We first try to get the organisation corresponding
organisation_id = 'site_%s' % object_id[:3] organisation_id = 'site_%s' % object_id[:3]
organisation = person_module_object.portal_catalog( organisation = organisation_module_object._getOb(organisation_id)
portal_type='Organisation', #organisation = person_module_object.portal_catalog(
id=organisation_id # portal_type='Organisation',
)[0].getObject() # id=organisation_id
# )[0].getObject()
subobject._setCareerSubordinationValue(organisation) subobject._setCareerSubordinationValue(organisation)
else: # This is an organisation object else: # This is an organisation object
...@@ -370,6 +380,11 @@ class BaobabConduit(ERP5Conduit): ...@@ -370,6 +380,11 @@ class BaobabConduit(ERP5Conduit):
# Get the person or organisation thanks to the portal_type # Get the person or organisation thanks to the portal_type
dest = findObjectFromSpecialPortalType(portal_type,object_id=object_id) dest = findObjectFromSpecialPortalType(portal_type,object_id=object_id)
if dest == None: return None if dest == None: return None
try:
subobject = dest._getOb(object_id)
except (AttributeError, KeyError, TypeError):
subobject = None
if subobject is None:
subobject = dest.newContent( portal_type = 'Agent' subobject = dest.newContent( portal_type = 'Agent'
, id = object_id , id = object_id
) )
...@@ -386,6 +401,11 @@ class BaobabConduit(ERP5Conduit): ...@@ -386,6 +401,11 @@ class BaobabConduit(ERP5Conduit):
# Get the person or organisation thanks to the portal_type # Get the person or organisation thanks to the portal_type
dest = findObjectFromSpecialPortalType(portal_type) dest = findObjectFromSpecialPortalType(portal_type)
if dest == None: return None if dest == None: return None
try:
subobject = dest._getOb(object_id)
except (AttributeError, KeyError, TypeError):
subobject = None
if subobject is None:
subobject = dest.newContent( portal_type = 'Agent Privilege' subobject = dest.newContent( portal_type = 'Agent Privilege'
, id = object_id , id = object_id
) )
...@@ -595,9 +615,11 @@ class BaobabConduit(ERP5Conduit): ...@@ -595,9 +615,11 @@ class BaobabConduit(ERP5Conduit):
# we should get only 1 bank account # we should get only 1 bank account
bank_account_list = [x.getObject() for x in object.portal_catalog( bank_account_list = [x.getObject() for x in object.portal_catalog(
portal_type=('Bank Account'), portal_type=('Bank Account'),
string_index=bank_account_number,
)] )]
# Make sure we have found the right bank account # Make sure we have found the right bank account
for bank_account in bank_account_list: for bank_account in bank_account_list:
LOG('BaobabConduit editDocument account number',0, (bank_account.getInternalBankAccountNumber(), bank_account_number))
if bank_account.getInternalBankAccountNumber() == bank_account_number: if bank_account.getInternalBankAccountNumber() == bank_account_number:
bank_account_object = bank_account bank_account_object = bank_account
break break
...@@ -808,6 +830,8 @@ class BaobabConduit(ERP5Conduit): ...@@ -808,6 +830,8 @@ class BaobabConduit(ERP5Conduit):
def editMandataireNom(self, document, value): def editMandataireNom(self, document, value):
# Convert mandataire_nom to first_name # Convert mandataire_nom to first_name
LOG('BaobabConduit.editMandataireNom, document', 0, document)
LOG('BaobabConduit.editMandataireNom, document.getAgentValue()', 0, document.getAgentValue())
old_value = document.getAgentValue().getFirstName() old_value = document.getAgentValue().getFirstName()
new_value = value new_value = value
if old_value != new_value: if old_value != new_value:
......
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