Commit a18b493a authored by Klaus Wölfel's avatar Klaus Wölfel

erp5_interface_cxml: .

parent 285343a1
......@@ -90,7 +90,7 @@ class CxmlConnector(XMLObject):
except AssertionError:
self.log(text_content)
self.log(response.content)
error_message = "Unexepected Response Status in response %s" %response_document.getRelativeUrl()
error_message = et.xpath('/cXML/Response/Status')[0].text
raise AssertionError(error_message)
return response_document
......
......@@ -136,8 +136,8 @@ class CxmlOrderRequest(CxmlDocument):
bill_to = order_request_header.find('BillTo')
address = bill_to.find('Address')
bill_to_name = get_text(address, 'Name')
sold_to_name = ''.join(order_request_header.xpath('//BusinessPartner[@role="soldTo"]/Address/Name/text()'))
buyer_vat_id = ''.join(order_request_header.xpath('//Extrinsic[@name="buyerVatID"]/text()'))
sold_to_name = s(''.join(order_request_header.xpath('//BusinessPartner[@role="soldTo"]/Address/Name/text()')))
buyer_vat_id = s(''.join(order_request_header.xpath('//Extrinsic[@name="buyerVatID"]/text()')))
property_dict['destination_section'] = {'portal_type': 'Organisation', 'corporate_name': sold_to_name or bill_to_name}
if buyer_vat_id:
property_dict['destination_section_vat_code'] = buyer_vat_id
......
......@@ -7,7 +7,7 @@ for start_date, cxml_document in reversed(sorted([(x.getStartDate(), x) for x in
# a status code 2xx. Only then we had a successfull
# ConfirmationRequest
if response.getStatusCode().startswith("2"):
return "Invoice accepted"
return "Invoice not accepted"
return "Invoice sent but no reply"
return "Invoice not sent"
return "accepted", context.Base_translateString("Invoice accepted")
return "not_accepted", context.Base_translateString("Invoice not accepted")
return "not_reply", context.Base_translateString("Invoice sent but no reply")
return "not_sent", context.Base_translateString("Invoice not sent")
......@@ -62,7 +62,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SaleInvoiceTransaction_getCxmlStatusText</string> </value>
<value> <string>SaleInvoiceTransaction_getCxmlStatusItem</string> </value>
</item>
</dictionary>
</pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SaleInvoiceTransaction_getExeptDetail</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -15,6 +15,7 @@
order python:here.getCausalityValue(portal_type='Sale Order');
order_request order/Order_getRelatedOrderRequestValue;
data_dict here/Invoice_getODTDataDict;
supplier_bank_account here/SaleInvoiceTransaction_getSupplierBankAccount;
connector here/Base_getCxmlConnectorValueForSale;">
<cXML tal:attributes="xml:lang language; payloadID connector/getPayloadId; timestamp python:DateTime().ISO8601(); version connector/getCxmlVersion">
<Header>
......@@ -90,6 +91,16 @@
</PostalAddress>
</Contact>
</InvoicePartner>
<InvoicePartner>
<Contact role="wireReceivingBank">
<Name xml:lang="en-US" tal:content="python: supplier_bank_account['bank_name']"></Name>
</Contact>
<IdReference domain="accountName" tal:attributes="identifier python: supplier_bank_account['title']"/>
<IdReference domain="accountType" tal:attributes="identifier python: supplier_bank_account['account_type']"/>
<IdReference domain="swiftID" tal:attributes="identifier python: supplier_bank_account['bic_code']"/>
<IdReference domain="accountID" tal:attributes="identifier python: supplier_bank_account['iban']"/>
<IdReference domain="ibanID" tal:attributes="identifier python: supplier_bank_account['iban']"/>
</InvoicePartner>
<InvoicePartner tal:content="structure order_request/getContactSoldToXml" />
<InvoiceDetailShipping>
<Contact role="shipFrom">
......@@ -102,7 +113,7 @@
<Country tal:attributes="isoCountryCode source_address/getRegionReference" tal:content="source_address/getRegionTitle"></Country>
</PostalAddress>
</Contact>
<Contact tal:attributes="addressID destination_address/getIntIndex" role="shipTo">
<Contact tal:attributes="addressID destination_address/getIntIndex" role="shipTo">
<Name tal:attributes="xml:lang language" tal:content="destination/Entity_getTitle"></Name>
<PostalAddress>
<Street tal:content="destination_address/getStreetAddress"></Street>
......@@ -170,7 +181,7 @@
<Tax>
<Money tal:attributes="currency here/getPriceCurrencyId" tal:content="line_tax/total_price"></Money>
<Description xml:lang = "en-US"></Description>
<TaxDetail category="vat" tal:attributes="percentageRate python: float(line_tax['base_price'] or 0) *100; taxPointDate python:here.getStartDate().ISO8601()">
<TaxDetail category="vat" tal:attributes="exemptDetail python: here.SaleInvoiceTransaction_getExeptDetail() or nothing; percentageRate python: float(line_tax['base_price'] or 0) *100; taxPointDate python:here.getStartDate().ISO8601()">
<TaxableAmount>
<Money tal:attributes="currency here/getPriceCurrencyId" tal:content="line_tax/total_quantity"></Money>
</TaxableAmount>
......
supplier = context.getSourceSectionValue()
supplier_bank_account = [x for x in supplier.objectValues(portal_type='Bank Account') if x.getValidationState() == 'validated'][0]
return dict(title = supplier_bank_account.getTitle(),
iban = supplier_bank_account.getIban(),
bic_code = supplier_bank_account.getBicCode(),
account_type = supplier_bank_account.getBankAccountType(),
bank_name = supplier_bank_account.getSourceFreeText()
)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SaleInvoiceTransaction_getSupplierBankAccount</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
#context = state_change['object']
# only send ShipNoticeRequest if the Sale Packing List is related to
# a Sale Order which is related to a valid Cxml Order Request
if not context.Base_isCxmlRelated():
return
text_content = context.SaleInvoiceTranaction_getInvoiceDetailRequest().encode('utf-8')
text_content = context.SaleInvoiceTransaction_getInvoiceDetailRequest().encode('utf-8')
connector = context.Base_getCxmlConnectorValueForSale()
connector.sendOutgoingRequest(text_content, follow_up=context.getRelativeUrl())
try:
context.SaleInvoiceTransaction_sendInvoiceDetailRequest()
except AssertionError as e:
context.Base_redirect(keep_items={"portal_status_message": str(e),
"portal_status_level": "error"})
else:
context.Base_redirect(keep_items={"portal_status_message":
context.Base_translateString('Cxml Invoice sent.')})
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SaleInvoiceTransaction_sendInvoiceDetailRequestAction</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -50,15 +50,18 @@ if destination_section_network_id != order_request_value.getFrom().rstrip("-Test
mapping=dict(destination_section_network_id=destination_section_network_id, from_network_id=order_request_value.getFrom().rstrip("-Test"))
))
try:
source_address = context.Delivery_getSourceAddressText()[0]
except AttributeError:
source_address = None
if source_address is None:
error_list.append(translate(
"Sender Address must be defined",
mapping=dict(destination_section_network_id=destination_section_network_id, from_network_id=order_request_value.getFrom().rstrip("-Test"))
))
if context.getPortalType() in ("Sale Packing List", "Sale Invoice Transaction"):
try:
source_address = context.Delivery_getSourceAddressText()[0]
except AttributeError:
source_address = None
if source_address is None:
error_list.append(translate("Sender Address must be defined"))
if context.getPortalType() == "Sale Invoice Transaction":
supplier_tax_id = context.SaleInvoiceTransaction_getSupplierTaxId()
if not supplier_tax_id:
error_list.append(translate("Supplier VAT Code must be defined."))
property_title_dict = {
"": "",
......@@ -154,6 +157,8 @@ def createSaleOrderLine(property_dict):
'validation_state' : 'validated',
})
property_dict['portal_type'] = 'Sale Order Line'
if property_dict.get('title') and not property_dict.get('description'):
property_dict['description'] = property_dict.get('title')
context.newContent(**property_dict)
def compare(document, property_dict, context_key='', context_title='', parent_context_title='', set_property=False):
......@@ -163,12 +168,14 @@ def compare(document, property_dict, context_key='', context_title='', parent_co
for key, value in sorted(property_dict.items()):
if context.getCxmlChanges():
continue
if context.getPortalType() in ("Sale Packing List", "Sale Invoice Transaction") and key in ('order_date', 'int_index'):
if document.getPortalType() in ("Sale Packing List", "Sale Invoice Transaction") and key in ('order_date', 'int_index'):
continue
if document.getPortalType() == "Invoice Line" and key in ('start_date', 'stop_date'):
continue
if context.getPortalType() in ("Sale Order", "Sale Packing List") and key == "destination_section_vat_code":
if document.getPortalType() in ("Sale Order", "Sale Packing List") and key == "destination_section_vat_code":
continue
if document.getPortalType() == "Sale Order Line" and key == "title" and set_property and not document.getDescription():
document.setDescription(value)
if isinstance(value, dict):
category = document.getProperty(key)
if not category:
......
......@@ -7,7 +7,7 @@ for start_date, cxml_document in reversed(sorted([(x.getStartDate(), x) for x in
# a status code 2xx. Only then we had a successfull
# ConfirmationRequest
if response.getStatusCode().startswith("2"):
return "ASN accepted"
return "ASN not accepted"
return "ASN sent but no reply"
return "ASN not sent"
return "accepted", context.Base_translateString("ASN accepted")
return "not_accepted", context.Base_translateString("ASN not accepted")
return "no_reply", context.Base_translateString("ASN sent but no reply")
return "not_sent", context.Base_translateString("ASN not sent")
......@@ -62,7 +62,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SalePackingList_getCxmlStatusText</string> </value>
<value> <string>SalePackingList_getCxmlStatusItem</string> </value>
</item>
</dictionary>
</pickle>
......
text_content = context.SalePackingList_getShipNoticeRequest().encode('utf-8')
connector = context.Base_getCxmlConnectorValueForSale()
connector.sendOutgoingRequest(text_content, follow_up=context.getRelativeUrl())
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SalePackingList_sendShipNoticeRequest</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
try:
context.SalePackingList_sendShipNoticeRequest()
except AssertionError as e:
context.Base_redirect(keep_items={"portal_status_message": str(e),
"portal_status_level": "error"})
else:
context.Base_redirect(keep_items={"portal_status_message":
context.Base_translateString('Cxml Ship Notice sent.')})
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SalePackingList_sendShipNoticeRequestAction</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -10,7 +10,7 @@
<key> <string>categories</string> </key>
<value>
<tuple>
<string>after_script/portal_workflow/cxml_interaction_workflow/script_SaleInvoiceTransaction_sendInvoiceDetailRequest</string>
<string>before_commit_script/portal_workflow/cxml_interaction_workflow/script_SaleInvoiceTransaction_sendInvoiceDetailRequest</string>
</tuple>
</value>
</item>
......
return
context = state_change['object']
# only send ShipNoticeRequest if the Sale Packing List is related to
# a Sale Order which is related to a valid Cxml Order Request
# only send if object is related to a valid Cxml Order Request
if not context.Base_isCxmlRelated():
return
text_content = context.SaleInvoiceTransaction_getInvoiceDetailRequest().encode('utf-8')
connector = context.Base_getCxmlConnectorValueForSale()
# calling sendOutgoingRequest should be done in an activity
# which NEVER retries.
connector.activate(
# call must be done in an activity which NEVER retries.
context.activate(
activity='SQLQueue',
conflict_retry=False,
max_retry=0,
).sendOutgoingRequest(text_content, follow_up=context.getRelativeUrl())
).SaleInvoiceTransaction_sendInvoiceDetailRequest()
return
context = state_change['object']
# only send ShipNoticeRequest if the Sale Packing List is related to
# a Sale Order which is related to a valid Cxml Order Request
# only send if object is related to a valid Cxml Order Request
if not context.Base_isCxmlRelated():
return
text_content = context.SalePackingList_getShipNoticeRequest().encode('utf-8')
connector = context.Base_getCxmlConnectorValueForSale()
# calling sendOutgoingRequest should be done in an activity
# which NEVER retries.
connector.activate(
# call must be done in an activity which NEVER retries.
context.activate(
activity='SQLQueue',
conflict_retry=False,
max_retry=0,
).sendOutgoingRequest(text_content, follow_up=context.getRelativeUrl())
).SalePackingList_sendShipNoticeRequest()
......@@ -35,7 +35,8 @@ else:
raise ValidationFailed(Message('erp5_ui', error))
clone_order = sale_order_value.Order_cloneAndUpdateVersion()
previous_order_request.setFollowUpValue(clone_order)
sale_order_value.update()
if portal.portal_workflow.isTransitionPossible(sale_order_value, 'update'):
sale_order_value.update()
break
else:
# we did not find another order request, so no need to clone
......
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