Commit 004d5200 authored by Klaus Wölfel's avatar Klaus Wölfel

erp5_interface_cxml: .

parent 56c533cb
...@@ -41,7 +41,41 @@ class CxmlMultipartDocument(XMLObject): ...@@ -41,7 +41,41 @@ class CxmlMultipartDocument(XMLObject):
security.declareObjectProtected(AccessContentsInformation) security.declareObjectProtected(AccessContentsInformation)
def getTitle(self): def getTitle(self):
return None return "%s %s" %(self.portal_type, self.getId())
security.declareProtected(ModifyPortalContent, 'checkParts')
def checkParts(self):
"CHeck Parts"
portal = self.getPortalObject()
output = ""
content = "content-length: %s\nContent-Type: %s\n%s" %(
self.getSize(),
self.getContentType(),
self.getData()
)
message = email.Parser.Parser().parsestr(content)
for part in message.walk():
output += part.get_content_type() + "\n"
if part.is_multipart():
continue
payload = part.get_payload(decode=0)
cxml_document_list = []
if part.get_content_type() == "application/pdf":
filename = part.get_filename()
pdf_document = portal.document_module.newContent(
portal_type = "PDF",
data = payload,
filename = filename,
title = filename.rstrip('.pdf'),
version = "001",
classification="collaborative/team",
group="woelfel/wws",
publication_section="verkauf/auftraege",
)
pdf_document.submit()
cxml_document_list.append(pdf_document)
self.setSuccessorValueList(self.getSuccessorValueList() + cxml_document_list)
return output
security.declareProtected(ModifyPortalContent, 'extract') security.declareProtected(ModifyPortalContent, 'extract')
def extract(self): def extract(self):
...@@ -54,17 +88,37 @@ class CxmlMultipartDocument(XMLObject): ...@@ -54,17 +88,37 @@ class CxmlMultipartDocument(XMLObject):
) )
message = email.Parser.Parser().parsestr(content) message = email.Parser.Parser().parsestr(content)
cxml_document_list = [] cxml_document_list = []
pdf_document_list = []
for part in message.walk(): for part in message.walk():
if part.is_multipart(): if part.is_multipart():
continue continue
payload = part.get_payload(decode=0) payload = part.get_payload(decode=0)
if "<OrderRequest>" in payload: if part.get_content_type() == "application/pdf":
portal_type = "Cxml Order Request" filename = part.get_filename()
pdf_document = portal.document_module.newContent(
portal_type = "PDF",
data = payload,
filename = filename,
title = filename.rstrip('.pdf'),
version = "001",
classification="collaborative/team",
group="woelfel/wws",
publication_section="verkauf/auftraege",
)
pdf_document.submit()
pdf_document_list.append(pdf_document)
else: else:
portal_type = "Cxml Document" if "<OrderRequest>" in payload:
cxml_document_list.append(portal.cxml_document_module.newContent( portal_type = "Cxml Order Request"
portal_type=portal_type, else:
text_content=payload, portal_type = "Cxml Document"
causality_value=self)) cxml_document_list.append(portal.cxml_document_module.newContent(
self.setSuccessorValueList(cxml_document_list) portal_type=portal_type,
text_content=payload,
causality_value=self))
for order_request in cxml_document_list:
if order_request.getPortalType() == "Cxml Order Request":
for pdf_document in pdf_document_list:
pdf_document.setFollowUpValue(order_request)
self.setSuccessorValueList(cxml_document_list + pdf_document_list)
return cxml_document_list return cxml_document_list
...@@ -95,6 +95,10 @@ ...@@ -95,6 +95,10 @@
<string>Cxml Order Request</string> <string>Cxml Order Request</string>
<string>Cxml Order Request</string> <string>Cxml Order Request</string>
</tuple> </tuple>
<tuple>
<string>PDF</string>
<string>PDF</string>
</tuple>
</list> </list>
</value> </value>
</item> </item>
......
return context.Order_getRelatedOrderRequestValue().getAribaAttachmentUrl() order_request = context.Order_getRelatedOrderRequestValue()
if order_request is not None:
return order_request.getAribaAttachmentUrl()
return ''
...@@ -199,8 +199,12 @@ def compare(document, property_dict, context_key='', context_title='', parent_co ...@@ -199,8 +199,12 @@ def compare(document, property_dict, context_key='', context_title='', parent_co
compare(category_value, value, context_key=key, parent_context_title=context_title) compare(category_value, value, context_key=key, parent_context_title=context_title)
else: else:
our_value = document.getProperty(key) our_value = document.getProperty(key)
if key == "quantity_unit" and value == "unit/piece" and our_value == "unit/set":
value = "unit/set"
if (our_value or '') != value: if (our_value or '') != value:
if set_property: if set_property:
if key == "quantity_unit" and document.getResourceValue() is None:
continue
document.setProperty(key, value) document.setProperty(key, value)
else: else:
title = translate(property_title_dict.get(key, key)) title = translate(property_title_dict.get(key, key))
......
...@@ -47,4 +47,9 @@ else: ...@@ -47,4 +47,9 @@ else:
error = translate("Could not validate. The OrderID of the Follow-Up Sale Order does not match." %sale_order.getTitle()) error = translate("Could not validate. The OrderID of the Follow-Up Sale Order does not match." %sale_order.getTitle())
raise ValidationFailed(Message('erp5_ui', error)) raise ValidationFailed(Message('erp5_ui', error))
sale_order_value.setVersion(context.getVersion()) sale_order_value.setVersion(context.getVersion())
# Attach PDF to Sale Order
for pdf in context.getFollowUpRelatedValueList(portal_type="PDF", checked_permission="Modify portal content"):
pdf.setFollowUpValueList(pdf.getFollowUpValueList() + [sale_order_value])
context.validate() context.validate()
...@@ -18,11 +18,19 @@ ...@@ -18,11 +18,19 @@
<tuple> <tuple>
<string>destination/portal_workflow/cxml_validation_workflow/transition_delete</string> <string>destination/portal_workflow/cxml_validation_workflow/transition_delete</string>
<string>destination/portal_workflow/cxml_validation_workflow/transition_delete_action</string> <string>destination/portal_workflow/cxml_validation_workflow/transition_delete_action</string>
<string>destination/portal_workflow/cxml_validation_workflow/transition_invalidate</string>
<string>destination/portal_workflow/cxml_validation_workflow/transition_invalidate_action</string>
<string>destination/portal_workflow/cxml_validation_workflow/transition_validate</string> <string>destination/portal_workflow/cxml_validation_workflow/transition_validate</string>
<string>destination/portal_workflow/cxml_validation_workflow/transition_validate_action</string> <string>destination/portal_workflow/cxml_validation_workflow/transition_validate_action</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <string>Default state of the document</string> </value> <value> <string>Default state of the document</string> </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