Allow to create manual payment

We display Stripe token and/or customer and we use the Stripe token as record
name for customer who has one.

issue6617
review37541002
This commit is contained in:
Cédric Krier
2017-07-26 23:59:16 +02:00
parent 55bdb3be95
commit 6be3778dc9
5 changed files with 26 additions and 3 deletions
+1
View File
@@ -1,3 +1,4 @@
* Allow to create manual payment
* Add capture
Version 4.4.0 - 2017-05-01
+16 -3
View File
@@ -90,7 +90,12 @@ class Payment:
stripe_capture_needed = fields.Function(
fields.Boolean("Stripe Capture Needed"),
'get_stripe_capture_needed')
stripe_token = fields.Char("Stripe Token", readonly=True)
stripe_token = fields.Char("Stripe Token",
states={
'invisible': ~Eval('stripe_journal') | Eval('stripe_customer'),
'readonly': ~Eval('state').in_(['draft', 'approved']),
},
depends=['stripe_journal', 'stripe_customer', 'state'])
stripe_error_message = fields.Char("Stripe Error Message", readonly=True,
states={
'invisible': ~Eval('stripe_error_message'),
@@ -104,12 +109,16 @@ class Payment:
'invisible': ~Eval('stripe_error_param'),
})
stripe_customer = fields.Many2One(
'account.payment.stripe.customer', "Stripe Customer", readonly=True,
'account.payment.stripe.customer', "Stripe Customer",
domain=[
('party', '=', Eval('party', -1)),
('stripe_account', '=', Eval('stripe_account', -1)),
],
depends=['party', 'stripe_account'])
states={
'invisible': ~Eval('stripe_journal') | Eval('stripe_token'),
'readonly': ~Eval('state').in_(['draft', 'approved']),
},
depends=['party', 'stripe_account', 'stripe_journal', 'state'])
stripe_account = fields.Function(fields.Many2One(
'account.payment.stripe.account', "Stripe Account"),
'on_change_with_stripe_account')
@@ -387,6 +396,10 @@ class Customer(ModelSQL, ModelView):
def get_stripe_checkout_needed(self, name):
return not self.stripe_token
def get_rec_name(self, name):
name = super(Customer, self).get_rec_name(name)
return self.stripe_token if self.stripe_token else name
@classmethod
def delete(cls, customers):
cls.write(customers, {
+3
View File
@@ -8,6 +8,9 @@ this repository contains the full copyright notices and license terms. -->
<field name="active"/>
<label name="stripe_account"/>
<field name="stripe_account"/>
<newline/>
<label name="stripe_token"/>
<field name="stripe_token"/>
<button string="Stripe Checkout" name="stripe_checkout" colspan="2"/>
<field name="stripe_checkout_needed" colspan="4" invisible="1"/>
<label name="stripe_error_message"/>
+1
View File
@@ -3,6 +3,7 @@
this repository contains the full copyright notices and license terms. -->
<tree>
<field name="party"/>
<field name="stripe_token"/>
<field name="stripe_account"/>
<button string="Stripe Checkout" name="stripe_checkout"/>
<field name="stripe_checkout_needed" tree_invisible="1"/>
+5
View File
@@ -7,6 +7,11 @@ this repository contains the full copyright notices and license terms. -->
<button string="Stripe Capture" name="stripe_capture_"/>
</xpath>
<xpath expr="//field[@name='date']" position="after">
<newline/>
<label name="stripe_customer"/>
<field name="stripe_customer" colspan="3"/>
<label name="stripe_token"/>
<field name="stripe_token" colspan="3"/>
<label name="stripe_capture"/>
<field name="stripe_capture"/>
</xpath>