Replace payment wizard confirmation by button
A button is easier for the user to discover than a keyword action. There is a small risk that user does not group the processing of payments but it existed also wizard the keyword action and it is compensated largely by the benefit of discoverability.
This commit is contained in:
@@ -11,7 +11,6 @@ def register():
|
||||
payment.Group,
|
||||
payment.Payment,
|
||||
account.MoveLine,
|
||||
payment.ProcessPaymentStart,
|
||||
account.CreateDirectDebitStart,
|
||||
account.PayLineStart,
|
||||
account.PayLineAskJournal,
|
||||
|
||||
@@ -21,7 +21,7 @@ from trytond.rpc import RPC
|
||||
from trytond.tools import (
|
||||
cursor_dict, grouped_slice, reduce_ids, sortable_values)
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.wizard import Button, StateAction, StateView, Wizard
|
||||
from trytond.wizard import StateAction, Wizard
|
||||
|
||||
from .exceptions import OverpayWarning
|
||||
|
||||
@@ -423,6 +423,14 @@ class Payment(Workflow, ModelSQL, ModelView):
|
||||
'icon': 'tryton-forward',
|
||||
'depends': ['state', 'kind'],
|
||||
},
|
||||
'process_wizard': {
|
||||
'invisible': ~(
|
||||
(Eval('state') == 'approved')
|
||||
| ((Eval('state') == 'submitted')
|
||||
& (Eval('kind') == 'receivable'))),
|
||||
'icon': 'tryton-launch',
|
||||
'depends': ['state', 'kind'],
|
||||
},
|
||||
'proceed': {
|
||||
'invisible': (
|
||||
~Eval('state').in_(['succeeded', 'failed'])
|
||||
@@ -578,6 +586,11 @@ class Payment(Workflow, ModelSQL, ModelView):
|
||||
def approve(cls, payments):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
@ModelView.button_action('account_payment.act_process_payments')
|
||||
def process_wizard(cls, payments):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
@Workflow.transition('processing')
|
||||
def process(cls, payments, group):
|
||||
@@ -619,19 +632,10 @@ class Payment(Workflow, ModelSQL, ModelView):
|
||||
pass
|
||||
|
||||
|
||||
class ProcessPaymentStart(ModelView):
|
||||
'Process Payment'
|
||||
__name__ = 'account.payment.process.start'
|
||||
|
||||
|
||||
class ProcessPayment(Wizard):
|
||||
'Process Payment'
|
||||
__name__ = 'account.payment.process'
|
||||
start = StateView('account.payment.process.start',
|
||||
'account_payment.payment_process_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Process', 'process', 'tryton-ok', default=True),
|
||||
])
|
||||
start_state = 'process'
|
||||
process = StateAction('account_payment.act_payment_group_form')
|
||||
|
||||
def _group_payment_key(self, payment):
|
||||
|
||||
@@ -503,6 +503,13 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="group" ref="group_payment_approval"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.model.button" id="payment_process_wizard_button">
|
||||
<field name="name">process_wizard</field>
|
||||
<field name="string">Process</field>
|
||||
<field name="model" search="[('model', '=', 'account.payment')]"/>
|
||||
<field name="confirm">Are you sure you want to process the payments?</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.model.button" id="payment_proceed_button">
|
||||
<field name="name">proceed</field>
|
||||
<field name="string">Processing</field>
|
||||
@@ -533,22 +540,10 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="group" ref="group_payment"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="payment_process_start_view_form">
|
||||
<field name="model">account.payment.process.start</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">payment_process_start_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.wizard" id="act_process_payments">
|
||||
<field name="name">Process Payments</field>
|
||||
<field name="wiz_name">account.payment.process</field>
|
||||
<field name="model">account.payment</field>
|
||||
</record>
|
||||
<record model="ir.action.keyword" id="act_process_payments_keyword1">
|
||||
<field name="keyword">form_action</field>
|
||||
<field name="model">account.payment,-1</field>
|
||||
<field name="action" ref="act_process_payments"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</tryton>
|
||||
|
||||
@@ -105,9 +105,10 @@ Partially pay line::
|
||||
True
|
||||
>>> payment.state
|
||||
'approved'
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> payment.reload()
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> group, = process_payment.actions[0]
|
||||
>>> group.payments == [payment]
|
||||
True
|
||||
>>> payment.state
|
||||
'processing'
|
||||
>>> line.reload()
|
||||
@@ -158,8 +159,7 @@ Partially fail to pay the remaining::
|
||||
Decimal('30.00')
|
||||
>>> payment.click('submit')
|
||||
>>> payment.click('approve')
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> line.reload()
|
||||
>>> line.payment_amount
|
||||
Decimal('0.00')
|
||||
|
||||
@@ -99,8 +99,10 @@ Create no dunning::
|
||||
Fail the payment::
|
||||
|
||||
>>> payment.click('submit')
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> group, = process_payment.actions[0]
|
||||
>>> group.payments == [payment]
|
||||
True
|
||||
>>> payment.click('fail')
|
||||
>>> payment.state
|
||||
'failed'
|
||||
|
||||
@@ -3,6 +3,7 @@ Invoice Payment Scenario
|
||||
========================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> import datetime
|
||||
>>> from decimal import Decimal
|
||||
>>> from proteus import Model, Wizard
|
||||
@@ -90,8 +91,7 @@ Check amount to pay::
|
||||
|
||||
Process the payment::
|
||||
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
|
||||
Check amount to pay::
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<button name="draft"/>
|
||||
<button name="submit"/>
|
||||
<button name="approve"/>
|
||||
<button name="process_wizard"/>
|
||||
<button name="proceed"/>
|
||||
<button name="fail"/>
|
||||
<button name="succeed"/>
|
||||
|
||||
@@ -11,6 +11,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<button name="draft"/>
|
||||
<button name="submit"/>
|
||||
<button name="approve"/>
|
||||
<button name="process_wizard"/>
|
||||
<button name="fail"/>
|
||||
<button name="succeed"/>
|
||||
</tree>
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<form col="2">
|
||||
<image name="tryton-warning" xexpand="0" xfill="0"/>
|
||||
<label string="Process Payments?" id="process"
|
||||
yalign="0.0" xalign="0.0" xexpand="1"/>
|
||||
</form>
|
||||
@@ -106,8 +106,7 @@ Checkout the payment::
|
||||
|
||||
Process the payment::
|
||||
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> payment.state
|
||||
'processing'
|
||||
>>> bool(payment.braintree_payment_settled)
|
||||
@@ -177,8 +176,7 @@ Make payment with customer::
|
||||
>>> payment.click('submit')
|
||||
>>> payment.state
|
||||
'submitted'
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> payment.state
|
||||
'processing'
|
||||
|
||||
@@ -219,8 +217,7 @@ Create payment to settle::
|
||||
... 'braintree_nonce': Nonces.Transactable,
|
||||
... }, config.context)
|
||||
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> payment.state
|
||||
'processing'
|
||||
|
||||
|
||||
+1
-3
@@ -91,9 +91,7 @@ Pay the line::
|
||||
>>> payment.click('approve')
|
||||
>>> payment.state
|
||||
'approved'
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> payment.reload()
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> payment.state
|
||||
'processing'
|
||||
|
||||
|
||||
@@ -101,9 +101,7 @@ Partially pay the line::
|
||||
>>> payment.click('approve')
|
||||
>>> payment.state
|
||||
'approved'
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> payment.reload()
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> payment.state
|
||||
'processing'
|
||||
|
||||
@@ -158,9 +156,7 @@ Pay the line::
|
||||
>>> payment.click('approve')
|
||||
>>> payment.state
|
||||
'approved'
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> payment.reload()
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> payment.state
|
||||
'processing'
|
||||
|
||||
@@ -364,9 +360,7 @@ Pay the line::
|
||||
Decimal('40.00')
|
||||
>>> payment.click('submit')
|
||||
>>> payment.click('approve')
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> payment.reload()
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> payment.state
|
||||
'processing'
|
||||
|
||||
@@ -406,9 +400,7 @@ Pay the line::
|
||||
>>> payment.amount
|
||||
Decimal('100.0')
|
||||
>>> payment.click('submit')
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> payment.reload()
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> payment.state
|
||||
'processing'
|
||||
|
||||
@@ -448,9 +440,7 @@ Create a processing payment for the move::
|
||||
>>> payment.click('approve')
|
||||
>>> payment.state
|
||||
'approved'
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> payment.reload()
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> payment.state
|
||||
'processing'
|
||||
|
||||
|
||||
+2
-6
@@ -97,9 +97,7 @@ Create and pay an invoice without clearing::
|
||||
>>> payment.click('submit')
|
||||
>>> payment.state
|
||||
'submitted'
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> payment.reload()
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> succeed = payment.click('succeed_wizard')
|
||||
>>> succeed.execute('succeed')
|
||||
|
||||
@@ -130,9 +128,7 @@ Create an invoice and pay it::
|
||||
>>> payment.click('submit')
|
||||
>>> payment.state
|
||||
'submitted'
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> payment.reload()
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> succeed = payment.click('succeed_wizard')
|
||||
>>> succeed.execute('succeed')
|
||||
|
||||
|
||||
@@ -117,8 +117,7 @@ Checkout the payment::
|
||||
|
||||
Process the payment::
|
||||
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> payment.state
|
||||
'processing'
|
||||
|
||||
@@ -155,8 +154,7 @@ Create failing payment::
|
||||
... 'stripe_chargeable': True,
|
||||
... 'stripe_payment_intent_id': None, # Remove intent from checkout
|
||||
... }, config.context)
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> payment.state
|
||||
'failed'
|
||||
>>> payment.stripe_error_code
|
||||
@@ -224,8 +222,7 @@ Make payment with customer::
|
||||
>>> payment.click('submit')
|
||||
>>> payment.state
|
||||
'submitted'
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> payment.state
|
||||
'processing'
|
||||
|
||||
@@ -290,8 +287,7 @@ Checkout the capture payment::
|
||||
|
||||
Process the capture payment::
|
||||
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> payment.state
|
||||
'processing'
|
||||
>>> bool(payment.stripe_captured)
|
||||
|
||||
@@ -100,8 +100,7 @@ Create fully disputed payment::
|
||||
... 'stripe_payment_intent_id': None, # Remove intent from checkout
|
||||
... }, config.context)
|
||||
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> payment.state
|
||||
'processing'
|
||||
|
||||
@@ -192,8 +191,7 @@ Create partial disputed payment::
|
||||
... 'stripe_payment_intent_id': None, # Remove intent from checkout
|
||||
... }, config.context)
|
||||
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> payment.state
|
||||
'processing'
|
||||
|
||||
@@ -262,8 +260,7 @@ Create won disputed payment::
|
||||
... 'stripe_payment_intent_id': None, # Remove intent from checkout
|
||||
... }, config.context)
|
||||
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> payment.state
|
||||
'processing'
|
||||
|
||||
|
||||
@@ -117,8 +117,7 @@ Create submitted payment::
|
||||
|
||||
Process off-session the payment::
|
||||
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> payment.state
|
||||
'processing'
|
||||
|
||||
@@ -164,8 +163,7 @@ Cancel payment intent::
|
||||
>>> payment.state
|
||||
'submitted'
|
||||
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> payment.state
|
||||
'processing'
|
||||
|
||||
|
||||
@@ -117,8 +117,7 @@ Attempt to cancel sale::
|
||||
|
||||
Revert sale to draft after failed payment::
|
||||
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> payment.click('fail')
|
||||
>>> payment.state
|
||||
'failed'
|
||||
@@ -181,8 +180,7 @@ Create and process a final payment::
|
||||
>>> payment.origin = sale
|
||||
>>> payment.amount = Decimal('60.00')
|
||||
>>> payment.click('submit')
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> payment.click('succeed')
|
||||
|
||||
The sale should be processing::
|
||||
|
||||
@@ -85,8 +85,7 @@ Pay the sale using payment::
|
||||
>>> payment.click('submit')
|
||||
>>> payment.state
|
||||
'submitted'
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> process_payment = payment.click('process_wizard')
|
||||
>>> payment.click('succeed')
|
||||
|
||||
The sale should be processing::
|
||||
|
||||
Reference in New Issue
Block a user