Commit fa27ca24 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_payzen: Skip invoice if payment was created on the same transaction or...

slapos_payzen: Skip invoice if payment was created on the same transaction or if the payment wasn't indexed yet
parent 97edd25d
...@@ -24,7 +24,14 @@ default_source_uid=portal.restrictedTraverse('account_module/receivable').getUid ...@@ -24,7 +24,14 @@ default_source_uid=portal.restrictedTraverse('account_module/receivable').getUid
movement_list = [] movement_list = []
id = 1 id = 1
for invoice in portal.portal_catalog(**select_kw): for invoice in portal.portal_catalog(**select_kw):
invoice.getObject().serialize() # in order to avoid selection in same transaction invoice.getObject().serialize() # in order to avoid selection on concurrent transactions
payment_tag = "sale_invoice_transaction_order_builder_%s" % invoice.getObject().getUid()
if context.REQUEST.get(payment_tag, None) is not None or \
context.portal_activities.countMessageWithTag(payment_tag) > 0:
# Invoice was selected before the payment be indexed or it was already created on this transaction
# so skip the invoice for now.
continue
quantity = 0. quantity = 0.
for movement in invoice.searchFolder(portal_type='Sale Invoice Transaction Line', for movement in invoice.searchFolder(portal_type='Sale Invoice Transaction Line',
default_source_uid=default_source_uid): default_source_uid=default_source_uid):
......
...@@ -162,6 +162,8 @@ class TestSlapOSPaymentTransactionOrderBuilder(SlapOSTestCaseMixin): ...@@ -162,6 +162,8 @@ class TestSlapOSPaymentTransactionOrderBuilder(SlapOSTestCaseMixin):
payment_list = self.fullBuild(uid=invoice.getUid()) payment_list = self.fullBuild(uid=invoice.getUid())
payment_list[0].cancel() payment_list[0].cancel()
self.tic() self.tic()
self.portal.REQUEST.set("sale_invoice_transaction_order_builder_%s" % invoice.getUid(), None)
payment_list = self.fullBuild(uid=invoice.getUid()) payment_list = self.fullBuild(uid=invoice.getUid())
self.tic() self.tic()
self.emptyBuild(uid=invoice.getUid()) self.emptyBuild(uid=invoice.getUid())
......
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