Commit 884a4698 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_accounting: Only reset if Payment Mode for supported modes

   This avoids edit already modified instances.
parent 2e934779
......@@ -6,4 +6,5 @@ assert "Sale Invoice Transaction" == context.getPortalType()
assert "stopped" == context.getSimulationState()
# Edit as Manager to workarround security when cancel Sale Invoice Transaction
context.edit(payment_mode=None)
if context.getPaymentMode() in ["payzen", "wechat"]:
context.edit(payment_mode=None)
......@@ -225,3 +225,27 @@ return context.getParentValue()""")
self.assertTrue(redirect.endswith('%s?portal_status_message=The%%20payment%%20mode%%20is%%20unsupported.' % sale_invoice_transaction.getRelativeUrl()),
"%s doesn't end with %s?portal_status_message=The%%20payment%%20mode%%20is%%20unsupported." % (redirect, sale_invoice_transaction.getRelativeUrl()))
def test_SaleInvoiceTransaction_resetPaymentMode(self):
sale_invoice_transaction = self.portal.accounting_module.newContent(portal_type="Sale Invoice Transaction")
sale_invoice_transaction.edit(payment_mode="unknown",
start_date=DateTime(),
stop_date=DateTime())
sale_invoice_transaction.confirm()
sale_invoice_transaction.start( )
sale_invoice_transaction.stop()
sale_invoice_transaction.SaleInvoiceTransaction_resetPaymentMode()
self.assertEqual(sale_invoice_transaction.getPaymentMode(), "unknown")
sale_invoice_transaction.edit(payment_mode="payzen")
sale_invoice_transaction.SaleInvoiceTransaction_resetPaymentMode()
self.assertEqual(sale_invoice_transaction.getPaymentMode(), None)
sale_invoice_transaction.edit(payment_mode="wechat")
sale_invoice_transaction.SaleInvoiceTransaction_resetPaymentMode()
self.assertEqual(sale_invoice_transaction.getPaymentMode(), None)
self.assertRaises(
Unauthorized,
sale_invoice_transaction.SaleInvoiceTransaction_resetPaymentMode,
REQUEST={})
\ No newline at end of file
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