diff --git a/account.py b/account.py
index 60d404ae13..a225f77341 100644
--- a/account.py
+++ b/account.py
@@ -202,23 +202,23 @@ class Payment(CheckoutMixin, BraintreeCustomerMethodMixin, metaclass=PoolMeta):
cls.amount.states['readonly'] &= ~Eval('braintree_settlement_needed')
cls.braintree_customer.states['readonly'] = (
- ~Eval('state').in_(['draft', 'approved'])
+ ~Eval('state').in_(['draft', 'submitted', 'approved'])
| Eval('braintree_nonce'))
cls.braintree_customer_method.states['invisible'] |= (
Eval('braintree_nonce'))
cls.braintree_customer_method.states['readonly'] = (
- ~Eval('state').in_(['draft', 'approved']))
+ ~Eval('state').in_(['draft', 'submitted', 'approved']))
cls.braintree_customer_method_selection.states['invisible'] |= (
Eval('braintree_nonce'))
cls.braintree_customer_method_selection.states['readonly'] = (
- ~Eval('state').in_(['draft', 'approved']))
+ ~Eval('state').in_(['draft', 'submitted', 'approved']))
cls._buttons.update({
'braintree_checkout': {
'invisible': (~Eval('state', 'draft').in_(
- ['approved', 'processing'])
+ ['submitted', 'approved', 'processing'])
| (Eval('process_method') != 'braintree')
| Eval('braintree_nonce')
| Eval('braintree_customer_method')),
@@ -529,12 +529,16 @@ class PaymentBraintreeRefund(Workflow, ModelSQL, ModelView):
states={
'readonly': Eval('state') != 'draft',
})
+ submitted_by = employee_field(
+ "Submitted by",
+ states=['submitted', 'approved', 'processing', 'succeeded', 'failed'])
approved_by = employee_field(
"Approved by",
states=['approved', 'processing', 'succeeded', 'failed'])
state = fields.Selection([
('draft', "Draft"),
+ ('submitted', "Submitted"),
('approved', "Approved"),
('processing', "Processing"),
('succeeded', "Succeeded"),
@@ -562,7 +566,8 @@ class PaymentBraintreeRefund(Workflow, ModelSQL, ModelView):
super().__setup__()
cls.__access__.add('payment')
cls._transitions |= set((
- ('draft', 'approved'),
+ ('draft', 'submitted'),
+ ('submitted', 'approved'),
('approved', 'processing'),
('processing', 'succeeded'),
('processing', 'failed'),
@@ -570,15 +575,20 @@ class PaymentBraintreeRefund(Workflow, ModelSQL, ModelView):
))
cls._buttons.update({
'draft': {
- 'invisible': Eval('state') != 'approved',
+ 'invisible': ~Eval('state').in_(['approved', 'submitted']),
'icon': 'tryton-back',
'depends': ['state'],
},
- 'approve': {
+ 'submit': {
'invisible': Eval('state') != 'draft',
'icon': 'tryton-forward',
'depends': ['state'],
},
+ 'approve': {
+ 'invisible': Eval('state') != 'submitted',
+ 'icon': 'tryton-forward',
+ 'depends': ['state'],
+ },
})
@classmethod
@@ -608,10 +618,17 @@ class PaymentBraintreeRefund(Workflow, ModelSQL, ModelView):
@classmethod
@ModelView.button
@Workflow.transition('draft')
- @reset_employee('approved_by')
+ @reset_employee('submitted_by', 'approved_by')
def draft(cls, refunds):
pass
+ @classmethod
+ @ModelView.button
+ @Workflow.transition('submitted')
+ @set_employee('submitted_by')
+ def submit(cls, refunds):
+ pass
+
@classmethod
@ModelView.button
@Workflow.transition('approved')
diff --git a/account.xml b/account.xml
index d0d372873c..2476e734cb 100644
--- a/account.xml
+++ b/account.xml
@@ -163,29 +163,36 @@ this repository contains the full copyright notices and license terms. -->
-
- Approved
+
+ To Approve
+
+
+
+
+
+ To Process
+
Processing
-
+
Succeeded
-
+
Failed
-
+
@@ -198,7 +205,7 @@ this repository contains the full copyright notices and license terms. -->
@@ -212,6 +219,16 @@ this repository contains the full copyright notices and license terms. -->
+
+ submit
+ Submit
+
+
+
+
+
+
+
approve
Approve
diff --git a/tests/scenario_account_payment_braintree.rst b/tests/scenario_account_payment_braintree.rst
index 5f19dc4585..c46a405e43 100644
--- a/tests/scenario_account_payment_braintree.rst
+++ b/tests/scenario_account_payment_braintree.rst
@@ -81,7 +81,7 @@ Create party::
>>> customer = Party(name="Customer")
>>> customer.save()
-Create approved payment::
+Create submitted payment::
>>> Payment = Model.get('account.payment')
>>> payment = Payment()
@@ -90,9 +90,9 @@ Create approved payment::
>>> payment.party = customer
>>> # Use random amount to prevent gateway rejection for duplicate
>>> payment.amount = amount = Decimal(random.randint(0, 1999))
- >>> payment.click('approve')
+ >>> payment.click('submit')
>>> payment.state
- 'approved'
+ 'submitted'
Checkout the payment::
@@ -175,9 +175,9 @@ Make payment with customer::
>>> _, method = Payment.get_braintree_customer_methods(payment.id, config.context)
>>> method_token, _ = method
>>> payment.braintree_customer_method = method_token
- >>> payment.click('approve')
+ >>> payment.click('submit')
>>> payment.state
- 'approved'
+ 'submitted'
>>> process_payment = Wizard('account.payment.process', [payment])
>>> process_payment.execute('process')
>>> payment.state
@@ -212,9 +212,9 @@ Create payment to settle::
>>> payment.braintree_customer = None
>>> payment.braintree_settle_payment = False
>>> payment.amount = amount = Decimal(random.randint(0, 1999))
- >>> payment.click('approve')
+ >>> payment.click('submit')
>>> payment.state
- 'approved'
+ 'submitted'
>>> Payment.write([payment.id], {
... 'braintree_nonce': Nonces.Transactable,
@@ -252,6 +252,7 @@ Refund some amount::
>>> refund = Refund()
>>> refund.payment = payment
>>> refund.amount = amount - 1
+ >>> refund.click('submit')
>>> refund.click('approve')
>>> cron_refund, = Cron.find([
... ('method', '=', 'account.payment.braintree.refund|braintree_refund'),
@@ -287,6 +288,7 @@ Try to refund more::
>>> refund = Refund()
>>> refund.payment = payment
>>> refund.amount = Decimal('10')
+ >>> refund.click('submit')
>>> refund.click('approve')
>>> cron_refund.click('run_once')
>>> refund.reload()
diff --git a/view/refund_form.xml b/view/refund_form.xml
index c3669933a7..fd590ed6b7 100644
--- a/view/refund_form.xml
+++ b/view/refund_form.xml
@@ -10,14 +10,16 @@ this repository contains the full copyright notices and license terms. -->
+
+
-
+
diff --git a/view/refund_list.xml b/view/refund_list.xml
index b2cac7b116..0207f4aafd 100644
--- a/view/refund_list.xml
+++ b/view/refund_list.xml
@@ -5,4 +5,6 @@ this repository contains the full copyright notices and license terms. -->
+
+