Skip to content

Commit

Permalink
Merge pull request #84 from tarunbhardwaj/develop
Browse files Browse the repository at this point in the history
Provision to update order status to magento #7364
  • Loading branch information
Sharoon Thomas committed Mar 26, 2015
2 parents 23826c0 + e5fde31 commit d9786fa
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,19 +624,22 @@ def export_order_status_to_magento(self):
return self

instance = self.magento_instance
if self.state == 'cancel':
increment_id = self.reference.split(instance.order_prefix)[1]
# This try except is placed because magento might not accept this
# order status change due to its workflow constraints.
# TODO: Find a better way to do it
try:
with magento.Order(
instance.url, instance.api_user, instance.api_key
) as order_api:
increment_id = self.reference.split(instance.order_prefix)[1]
# This try except is placed because magento might not accept this
# order status change due to its workflow constraints.
# TODO: Find a better way to do it
try:
with magento.Order(
instance.url, instance.api_user, instance.api_key
) as order_api:
if self.state == 'cancel':
order_api.cancel(increment_id)
except xmlrpclib.Fault, exception:
if exception.faultCode == 103:
return self
elif self.state == 'done':
# TODO: update shipping and invoice
order_api.addcomment(increment_id, 'complete')
except xmlrpclib.Fault, exception:
if exception.faultCode == 103:
return self

return self

Expand Down

0 comments on commit d9786fa

Please sign in to comment.