[IMP] sale,account: Improve payment acquirers onboarding step

Purpose
=======

- Propose other payment acquired than the predefined ones
- Improve the layout for this step
This commit is contained in:
eco-odoo
2018-08-10 16:50:54 +02:00
committed by Yannick Tivisse
parent 9c4215b9b2
commit 687f9243bd
8 changed files with 49 additions and 47 deletions
@@ -74,7 +74,7 @@
<t t-set="bg_image">/account/static/src/img/account_invoice_onboarding_bg.jpg</t>
<t t-set="close_method">action_close_account_invoice_onboarding</t>
<t t-set="close_model">res.company</t>
<t t-set="text_completed">Congratulations! You are all set. You can now issue real invoices to your customers.</t>
<t t-set="text_completed">Congratulations! You are all set.</t>
<t t-call="base.onboarding_company_step" name="company_step" />
<t t-call="account.onboarding_invoice_layout_step" name="invoice_layout_step" />
@@ -149,7 +149,7 @@
<template id="onboarding_sale_tax_step">
<t t-call="base.onboarding_step">
<t t-set="title">Taxes</t>
<t t-set="description">Choose a default tax.</t>
<t t-set="description">Choose a default sales tax for your products.</t>
<t t-set="btn_text">I'm ready</t>
<t t-set="done_text">Step Completed!</t>
<t t-set="method" t-value="'action_open_account_onboarding_sale_tax'" />
+1
View File
@@ -13,6 +13,7 @@ class ResCompany(models.Model):
('paypal', "PayPal"),
('stripe', "Stripe"),
('manual', "Manual"),
('other', "Other"),
], string="Selected onboarding payment method")
@api.model
@@ -28,20 +28,13 @@
<form string="Choose a payment method" class="o_onboarding_payment_acquirer_wizard">
<div class="container">
<div class="row align-items-start">
<div class="col col-2" name="left-column">
<field name="payment_method" widget="radio"/>
<div class="col col-4" name="left-column">
<group>
<field name="payment_method" widget="radio" nolabel="1"/>
</group>
</div>
<div class="col offset-md-1" name="right-column">
<div attrs="{'invisible': [('payment_method', '!=', 'paypal')]}">
<p>
<a href="https://www.paypal.com" target="_blank">PayPal</a>
is the easiest way to accept payments. It's easy to configure
and it offers
<a href="https://www.paypal.com/us/webapps/mpp/merchant-fees"
target="_blank">
a transparent fee structure.
</a>
</p>
<group>
<field name="paypal_email_account" attrs="{'required': [('payment_method', '=', 'paypal')]}" />
<field name="paypal_seller_account" attrs="{'required': [('payment_method', '=', 'paypal')]}" />
@@ -49,19 +42,11 @@
</group>
<p>
<a href="https://www.paypal.com/ca/webapps/mpp/product-selection" target="_blank">
<span class="fa fa-arrow-right"> Create a PayPal Account</span>
<span class="fa fa-arrow-right"> Create a PayPal account</span>
</a>
</p>
</div>
<div attrs="{'invisible': [('payment_method', '!=', 'stripe')]}">
<p>
<a href="https://stripe.com" target="_blank">Stripe</a>
is a payment provider with-->
<a href="https://stripe.com/pricing" target="_blank">
a simple fee structure and no hidden costs.
</a>
We recommend it to manage credit card payments.
</p>
<group>
<field name="stripe_secret_key"
attrs="{'required': [('payment_method', '=', 'stripe')]}" />
@@ -74,8 +59,16 @@
</a>
</p>
</div>
<div attrs="{'invisible': [('payment_method', '!=', 'other')]}">
<a type="action" role="button" name="payment.action_payment_acquirer">
Check here
</a>
to choose another payment method.
</div>
<div attrs="{'invisible': [('payment_method', '!=', 'manual')]}">
<group>
<field name="manual_name" attrs="{'required': [('payment_method', '=', 'manual')]}"/>
<field name="journal_name" attrs="{'required': [('payment_method', '=', 'manual')]}"/>
<field name="acc_number" attrs="{'required': [('payment_method', '=', 'manual')]}"/>
<field name="manual_post_msg" attrs="{'required': [('payment_method', '=', 'manual')]}"/>
@@ -9,9 +9,10 @@ class PaymentWizard(models.TransientModel):
_name = 'payment.acquirer.onboarding.wizard'
payment_method = fields.Selection([
('paypal', "PayPal"),
('stripe', "Credit Card (via Stripe)"),
('manual', "Wire Transfer"),
('paypal', "Pay with PayPal"),
('stripe', "Pay with credit card (via Stripe)"),
('other', "Pay with another payment acquirer"),
('manual', "Custom payment instructions"),
], string="Payment Method", default=lambda self: self._get_default_payment_acquirer_onboarding_value('payment_method'))
paypal_email_account = fields.Char("PayPal Email ID", default=lambda self: self._get_default_payment_acquirer_onboarding_value('paypal_email_account'))
@@ -21,7 +22,8 @@ class PaymentWizard(models.TransientModel):
stripe_secret_key = fields.Char(default=lambda self: self._get_default_payment_acquirer_onboarding_value('stripe_secret_key'))
stripe_publishable_key = fields.Char(default=lambda self: self._get_default_payment_acquirer_onboarding_value('stripe_publishable_key'))
journal_name = fields.Char("Journal Name", default=lambda self: self._get_default_payment_acquirer_onboarding_value('journal_name'))
manual_name = fields.Char("Method", default=lambda self: self._get_default_payment_acquirer_onboarding_value('manual_name'))
journal_name = fields.Char("Bank Name", default=lambda self: self._get_default_payment_acquirer_onboarding_value('journal_name'))
acc_number = fields.Char("Account Number", default=lambda self: self._get_default_payment_acquirer_onboarding_value('acc_number'))
manual_post_msg = fields.Html("Payment instructions")
@@ -69,6 +71,7 @@ class PaymentWizard(models.TransientModel):
manual_payment = self._get_manual_payment_acquirer()
journal = manual_payment.journal_id
self._payment_acquirer_onboarding_cache['manual_name'] = manual_payment['name']
self._payment_acquirer_onboarding_cache['manual_post_msg'] = manual_payment['post_msg']
self._payment_acquirer_onboarding_cache['journal_name'] = journal.name if journal.name != "Bank" else ""
self._payment_acquirer_onboarding_cache['acc_number'] = journal.bank_acc_number
@@ -80,6 +83,9 @@ class PaymentWizard(models.TransientModel):
if module.state not in ('installed', 'to install', 'to upgrade'):
module.button_immediate_install()
def _on_save_payment_acquirer(self):
self._install_module('account_payment')
@api.multi
def add_payment_methods(self):
""" Install required payment acquiers, configure them and mark the
@@ -91,7 +97,9 @@ class PaymentWizard(models.TransientModel):
if self.payment_method == 'stripe':
self._install_module('payment_stripe')
if self.payment_method in ('paypal', 'stripe', 'manual'):
if self.payment_method in ('paypal', 'stripe', 'manual', 'other'):
self._on_save_payment_acquirer()
self.env.user.company_id.payment_onboarding_payment_method = self.payment_method
@@ -113,6 +121,7 @@ class PaymentWizard(models.TransientModel):
})
if self.payment_method == 'manual':
manual_acquirer = self._get_manual_payment_acquirer(new_env)
manual_acquirer.name = self.manual_name
manual_acquirer.post_msg = self.manual_post_msg
manual_acquirer.website_published = True
+2 -2
View File
@@ -17,11 +17,11 @@ class ResCompany(models.Model):
sale_onboarding_sample_quotation_state = fields.Selection([('not_done', "Not done"), ('just_done', "Just done"), ('done', "Done")], string="State of the onboarding sample quotation step", default='not_done')
sale_onboarding_payment_method = fields.Selection([
('digital_signature', 'Digital signature, without payment'),
('digital_signature', 'Sign online'),
('paypal', 'PayPal'),
('stripe', 'Stripe'),
('other', 'Pay with another payment acquirer'),
('manual', 'Wire Transfer'),
('none', 'No digital signature or payment'),
], string="Sale onboarding selected payment method")
@api.model
+2 -11
View File
@@ -14,7 +14,7 @@
</template>
<template id="sale_onboarding_order_confirmation_step">
<t t-call="base.onboarding_step">
<t t-set="title">Confirmation &amp; payment</t>
<t t-set="title">Confirmation &amp; Payment</t>
<t t-set="description">Choose how to confirm quotations and get paid.</t>
<t t-set="method" t-value="'action_open_sale_onboarding_payment_acquirer'" />
<t t-set="model" t-value="'res.company'" />
@@ -55,19 +55,10 @@
<xpath expr="//div[@name='left-column']" position="attributes">
<attribute name="class">col col-4</attribute>
</xpath>
<xpath expr="//div[@name='right-column']" position="inside">
<div attrs="{'invisible': [('payment_method', '!=', 'digital_signature')]}">
Digital signature offers as much legal guarantee as a paper signature, with way
more convenience for all parties.
</div>
<div attrs="{'invisible': [('payment_method', '!=', 'none')]}">
The salesperson confirms the quotation, after receiving an approval by email, a call, etc.
</div>
</xpath>
</field>
</record>
<record id="action_open_sale_onboarding_payment_acquirer_wizard" model="ir.actions.act_window">
<field name="name">Choose a payment method</field>
<field name="name">How your customers can confirm an order</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.payment.acquirer.onboarding.wizard</field>
<field name="view_type">form</field>
@@ -14,11 +14,11 @@ class PaymentWizard(models.TransientModel):
return self.env.user.company_id.sale_onboarding_payment_method
payment_method = fields.Selection([
('digital_signature', 'Digital signature, without payment'),
('paypal', 'PayPal'),
('stripe', 'Stripe'),
('manual', 'Wire Transfer'),
('none', 'No digital signature or payment'),
('digital_signature', 'Sign online'),
('paypal', "Pay with PayPal"),
('stripe', "Pay with credit card (via Stripe)"),
('other', "Pay with another payment acquirer"),
('manual', "Custom payment instructions"),
], default=_get_default_payment_method)
#
@@ -26,11 +26,19 @@ class PaymentWizard(models.TransientModel):
""" Override. """
self.env.user.company_id.set_onboarding_step_done('sale_onboarding_order_confirmation_state')
def _on_save_payment_acquirer(self, *args, **kwargs):
""" Override """
self._install_module('sale_payment')
return super(PaymentWizard, self)._on_save_payment_acquirer(*args, **kwargs)
@api.multi
def add_payment_methods(self, *args, **kwargs):
self.env.user.company_id.sale_onboarding_payment_method = self.payment_method
if self.payment_method == 'digital_signature':
self.env.user.company_id.portal_confirmation_sign = True
if self.payment_method in ('paypal', 'stripe'):
self.env.user.company_id.portal_confirmation_pay = True # TODO self.digital_signature
self.env.user.company_id.portal_confirmation_pay = True
return super(PaymentWizard, self).add_payment_methods(*args, **kwargs)
+1 -1
View File
@@ -41,7 +41,7 @@
<i class="fa fa-check text-success mr8" />
<span class="h3 mr16">
<t t-if="text_completed" t-esc="text_completed" />
<t t-else="">Nice work!</t>
<t t-else="">Nice work! Your configuration is done.</t>
</span>
<div class="btn btn-primary btn-sm">
<a type="action" class="btn btn-primary" data-toggle="collapse" href=".o_onboarding_container"