[IMP] payment: support SEPA Direct Debit acquirer

The purpose of this commit is to expose SEPA Direct Debit acquirer to
the Odoo community edition. The dedicated module, though, is restricted
to the enterprise edition.

Minor changes in following modules:

- base: added ir.module.module record

- payment:
  - added data to expose the new payment acquirer.
  - added 'to_buy' field to track whether the payment acquirer is
    restricted to enterprise users.
  - allow multi word payment acquirer name. It was breaking on the first
    underscore.

task-1870363
closes odoo/odoo#26427
This commit is contained in:
Johan Demaret Rivarola
2019-08-16 15:52:39 +00:00
committed by Damien Bouvy
parent d72117dcd0
commit e01d559f9d
6 changed files with 36 additions and 4 deletions
@@ -279,4 +279,17 @@
<!-- https://intl.alipay.com/ihome/home/about/buy.htm?topic=paymentMethods -->
<field name="payment_icon_ids" eval='[(6, 0, [ref("payment.payment_icon_cc_jcb"),ref("payment.payment_icon_cc_mastercard"),ref("payment.payment_icon_cc_western_union"),ref("payment.payment_icon_cc_webmoney"),ref("payment.payment_icon_cc_visa")])]'/>
</record>
<record id="payment.payment_acquirer_sepa_direct_debit" model="payment.acquirer">
<field name="name">SEPA Direct Debit</field>
<field name="view_template_id" ref="default_acquirer_button"/>
<field name="image_128" type="base64" file="base/static/img/icons/payment_sepa_direct_debit.png"/>
<field name="module_id" ref="base.module_payment_sepa_direct_debit"/>
<field name="description" type="html">
<p>
SEPA Direct Debit is a Europe-wide Direct Debit system that allows merchants to collect Euro-denominated payments from accounts in the 34 SEPA countries and associated territories.
</p>
</field>
</record>
</odoo>
+2 -1
View File
@@ -154,6 +154,7 @@ class PaymentAcquirer(models.Model):
# TDE FIXME: remove that brol
module_id = fields.Many2one('ir.module.module', string='Corresponding Module')
module_state = fields.Selection(selection=ir_module.STATES, string='Installation State', related='module_id.state', store=True)
module_to_buy = fields.Boolean(string='Odoo Enterprise Module', related='module_id.to_buy', readonly=True, store=False)
image_128 = fields.Image("Image", max_width=128, max_height=128)
@@ -271,7 +272,7 @@ class PaymentAcquirer(models.Model):
# If the trigger comes from the chart template wizard, the modules are already installed.
acquirer_modules = self.env['ir.module.module'].search(
[('name', 'like', 'payment_%'), ('state', 'in', ('to install', 'installed'))])
acquirer_names = [a.name.split('_')[1] for a in acquirer_modules]
acquirer_names = [a.name.split('_', 1)[1] for a in acquirer_modules]
# Search for acquirers having no journal
company = company or self.env.company
@@ -71,7 +71,7 @@ odoo.define('payment.processing', function (require) {
'tx_error': [],
};
if (transactions.length > 0 && transactions[0].acquirer_provider == 'transfer') {
if (transactions.length > 0 && ['transfer', 'sepa_direct_debit'].indexOf(transactions[0].acquirer_provider) >= 0) {
window.location = transactions[0].return_url;
return;
}
+10 -2
View File
@@ -20,12 +20,14 @@
<sheet>
<field name="module_id" invisible="1"/>
<field name="module_state" invisible="1"/>
<field name="module_to_buy" invisible="1"/>
<field name="inbound_payment_method_ids" invisible="1"/>
<field name="image_128" widget="image" class="oe_avatar"/>
<div class="oe_title">
<h1><field name="name" placeholder="Name"/></h1>
<div attrs="{'invisible': ['|', ('module_state', '=', 'installed'), ('module_id', '=', False)]}">
<button type="object" class="btn btn-primary" name="button_immediate_install" string="Install"/>
<a attrs="{'invisible': [('module_to_buy', '=', False)]}" href="https://odoo.com/pricing?utm_source=db&amp;utm_medium=module" class="btn btn-info" role="button">Upgrade</a>
<button attrs="{'invisible': [('module_to_buy', '=', True)]}" type="object" class="btn btn-primary" name="button_immediate_install" string="Install"/>
</div>
</div>
<div attrs="{'invisible': ['|', ('module_state', '=', 'installed'), ('module_id', '=', False)]}">
@@ -104,10 +106,12 @@
<field name="provider"/>
<field name="module_id"/>
<field name="module_state"/>
<field name="module_to_buy"/>
<field name="color"/>
<templates>
<t t-name="kanban-box">
<t t-set="installed" t-value="!record.module_id.value || (record.module_id.value &amp;&amp; record.module_state.raw_value === 'installed')"/>
<t t-set="to_buy" t-value="record.module_to_buy.raw_value === true"/>
<div t-attf-class="oe_kanban_global_click #{kanban_color(record.color.raw_value)}">
<div class="o_kanban_image">
<img type="open" t-att-src="kanban_image('payment.acquirer', 'image_128', record.id.raw_value)" alt="Acquirer"/>
@@ -120,7 +124,11 @@
<t t-if="installed">
<field name="state" widget="label_selection" options="{'classes': {'enabled': 'success', 'test': 'warning', 'disabled' : 'danger'}}"/>
</t>
<button t-if="!installed and !selection_mode" type="object" class="btn btn-secondary float-right" name="button_immediate_install">Install</button>
<button t-if="!installed and !selection_mode and !to_buy" type="object" class="btn btn-secondary float-right" name="button_immediate_install">Install</button>
<t t-if="!installed and to_buy">
<button href="https://odoo.com/pricing?utm_source=db&amp;utm_medium=module" class="btn btn-info btn-sm float_right">Upgrade</button>
<span class="badge badge-primary oe_inline o_enterprise_label">Enterprise</span>
</t>
<button t-if="installed and record.state.raw_value == 'disabled' and !selection_mode" type="edit" class="btn btn-primary float-right">Activate</button>
<button t-if="installed and record.state.raw_value in ['enabled', 'test'] and !selection_mode" type="edit" class="btn btn-primary float-right">Configure</button>
</div>
@@ -245,5 +245,15 @@
<field name="icon">/base/static/img/icons/website_twitter_wall.png</field>
</record>
<record model="ir.module.module" id="base.module_payment_sepa_direct_debit">
<field name="name">payment_sepa_direct_debit</field>
<field name="shortdesc">Sepa Direct Debit Payment Acquirer</field>
<field name="summary">Checkout with SEPA Direct Debit</field>
<field name="category_id" ref="base.module_category_accounting_invoicing"/>
<field name="license">OEEL-1</field>
<field name="author">Odoo S.A.</field>
<field name="to_buy" eval="True"/>
<field name="icon">/base/static/img/icons/payment_sepa_direct_debit.png</field>
</record>
</data>
</odoo>
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB