diff --git a/product/ERP5SyncML/Subscription.py b/product/ERP5SyncML/Subscription.py index 97615d86a870d86ff3c962423e1e0eda42b176d3..7b2cf64147f2503921779257d45b3cc2f1a31851 100644 --- a/product/ERP5SyncML/Subscription.py +++ b/product/ERP5SyncML/Subscription.py @@ -932,11 +932,11 @@ class Subscription(Folder, SyncCode): xml_mapping = getattr(self, 'xml_mapping', None) return xml_mapping - def getXMLFromObject(self, object): + def getXMLFromObject(self, object, force=0): """ return the xml mapping """ - xml_mapping = self.getXMLMapping() + xml_mapping = self.getXMLMapping(force=force) xml = '' if xml_mapping is not None: func = getattr(object, xml_mapping, None) diff --git a/product/ERP5SyncML/XMLSyncUtils.py b/product/ERP5SyncML/XMLSyncUtils.py index 56077b11f3b165105ee3e69c04a5e9e3ac71a08f..3fe6c838861d8ad72c781e8e1459e87064c09606 100644 --- a/product/ERP5SyncML/XMLSyncUtils.py +++ b/product/ERP5SyncML/XMLSyncUtils.py @@ -1090,8 +1090,8 @@ class XMLSyncUtilsMixin(SyncCode): data_subnode = self.getDataSubNode(action) if action.nodeName == 'Add': # Then store the xml of this new subobject + reset = 0 if object is None: - #if object_id is not None: add_data = conduit.addNode(xml=data_subnode, object=destination, object_id=object_id) if add_data['conflict_list'] not in ('', None, []): @@ -1103,6 +1103,7 @@ class XMLSyncUtilsMixin(SyncCode): signature.setPath(object.getPhysicalPath()) signature.setObjectId(object.getId()) else: + reset = 1 #Object was retrieve but need to be updated without recreated #usefull when an object is only deleted by workflow. add_data = conduit.addNode(xml=data_subnode, @@ -1113,17 +1114,21 @@ class XMLSyncUtilsMixin(SyncCode): conflict_list += add_data['conflict_list'] if object is not None: #LOG('SyncModif',0,'addNode, found the object') - #mapping = getattr(object,domain.getXMLMapping(),None) - xml_object = domain.getXMLFromObject(object) - #if mapping is not None: - # xml_object = mapping() + if reset: + #After a reset we want copy the LAST XML view on Signature. + #this implementation is not sufficient, need to be improved. + string_io = StringIO() + PrettyPrint(data_subnode, stream=string_io) + xml_object = string_io.getvalue() + else: + xml_object = domain.getXMLFromObject(object) signature.setStatus(self.SYNCHRONIZED) #signature.setId(object.getId()) signature.setPath(object.getPhysicalPath()) signature.setXML(xml_object) xml_confirmation += self.SyncMLConfirmation( - cmd_id=cmd_id, - cmd='Add', + cmd_id=cmd_id, + cmd='Add', sync_code=self.ITEM_ADDED, remote_xml=action) cmd_id +=1