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

erp5_interface_cxml: .

parent 56c533cb
......@@ -41,7 +41,41 @@ class CxmlMultipartDocument(XMLObject):
security.declareObjectProtected(AccessContentsInformation)
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')
def extract(self):
......@@ -54,17 +88,37 @@ class CxmlMultipartDocument(XMLObject):
)
message = email.Parser.Parser().parsestr(content)
cxml_document_list = []
pdf_document_list = []
for part in message.walk():
if part.is_multipart():
continue
payload = part.get_payload(decode=0)
if "<OrderRequest>" in payload:
portal_type = "Cxml Order Request"
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()
pdf_document_list.append(pdf_document)
else:
portal_type = "Cxml Document"
cxml_document_list.append(portal.cxml_document_module.newContent(
portal_type=portal_type,
text_content=payload,
causality_value=self))
self.setSuccessorValueList(cxml_document_list)
if "<OrderRequest>" in payload:
portal_type = "Cxml Order Request"
else:
portal_type = "Cxml Document"
cxml_document_list.append(portal.cxml_document_module.newContent(
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
......@@ -95,6 +95,10 @@
<string>Cxml Order Request</string>
<string>Cxml Order Request</string>
</tuple>
<tuple>
<string>PDF</string>
<string>PDF</string>
</tuple>
</list>
</value>
</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
compare(category_value, value, context_key=key, parent_context_title=context_title)
else:
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 set_property:
if key == "quantity_unit" and document.getResourceValue() is None:
continue
document.setProperty(key, value)
else:
title = translate(property_title_dict.get(key, key))
......
......@@ -47,4 +47,9 @@ else:
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))
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()
......@@ -18,11 +18,19 @@
<tuple>
<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_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_action</string>
</tuple>
</value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<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