[IMP] payment: support defining payment providers for specific countries.
This commit is contained in:
committed by
Yannick Tivisse
parent
cac170de23
commit
542201eed3
@@ -78,6 +78,10 @@ class PaymentAcquirer(models.Model):
|
||||
journal_id = fields.Many2one(
|
||||
'account.journal', 'Payment Journal',
|
||||
help="Account journal used for automatic payment reconciliation.")
|
||||
country_ids = fields.Many2many(
|
||||
'res.country', 'payment_country_rel',
|
||||
'payment_id', 'country_id', 'Countries',
|
||||
help="This payment gateway is available for selected countries. If none is selected it is available for all countries.")
|
||||
|
||||
pre_msg = fields.Html(
|
||||
'Help Message', translate=True,
|
||||
|
||||
@@ -82,6 +82,7 @@
|
||||
<field name="auto_confirm" widget="radio"/>
|
||||
<field name="save_token" widget="radio" attrs="{'invisible': [('token_implemented', '=', False)]}"/>
|
||||
<field name="journal_id" attrs="{'required': [('auto_confirm', '=', 'generate_and_pay_invoice')], 'invisible': [('auto_confirm', '!=', 'generate_and_pay_invoice')]}"/>
|
||||
<field name="country_ids" widget="many2many_tags"/>
|
||||
<label for="view_template_id" groups="base.group_no_one"/>
|
||||
<div groups="base.group_no_one">
|
||||
<field name="view_template_id" nolabel="1"/>
|
||||
|
||||
@@ -337,14 +337,23 @@
|
||||
<div class="col-md-6">
|
||||
<h4>Payment Method:</h4>
|
||||
<ul class="list-unstyled">
|
||||
<t t-set="payment_methods_available" t-value="False"/>
|
||||
<li t-foreach="acquirers or []" t-as="acquirer">
|
||||
<label t-if="buttons.get(acquirer.id)">
|
||||
<input t-att-value="acquirer.id" type="radio" name="acquirer" t-att-checked="acquirers[0] == acquirer"/>
|
||||
<img class="media-object" style="width: 60px; display: inline-block;"
|
||||
t-att-title="acquirer.name"
|
||||
t-att-src="'/payment_%s/static/src/img/%s_icon.png' % (acquirer.provider, acquirer.provider)"/>
|
||||
<span t-field="acquirer.name"/>
|
||||
</label>
|
||||
<t t-if="not acquirer.country_ids or quotation and quotation.partner_id.country_id in acquirer.country_ids">
|
||||
<label t-if="buttons.get(acquirer.id)">
|
||||
<input t-att-value="acquirer.id" type="radio" name="acquirer" t-att-checked="acquirers[0] == acquirer"/>
|
||||
<img class="media-object" style="width: 60px; display: inline-block;"
|
||||
t-att-title="acquirer.name"
|
||||
t-att-src="'/payment_%s/static/src/img/%s_icon.png' % (acquirer.provider, acquirer.provider)"/>
|
||||
<span t-field="acquirer.name"/>
|
||||
</label>
|
||||
<t t-set="payment_methods_available" t-value="True"/>
|
||||
</t>
|
||||
</li>
|
||||
<li t-if="not payment_methods_available">
|
||||
<div class="alert alert-warning">
|
||||
<span>No payment gateway is available for your country</span>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -353,9 +362,9 @@
|
||||
<div t-att-data-id="acquirer.id" class="oe_quote_acquirer_button hidden pull-right">
|
||||
<div t-raw="buttons.get(acquirer.id)"/>
|
||||
<div t-field="acquirer.pre_msg"/>
|
||||
<button type="button" class="btn btn-link" data-dismiss="modal" style="padding: 0">Cancel</button>
|
||||
</div>
|
||||
</t>
|
||||
<button type="button" class="btn btn-link" data-dismiss="modal" style="padding: 0">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end website_sale code -->
|
||||
|
||||
@@ -1341,17 +1341,25 @@
|
||||
<div class="col-lg-5 col-sm-6">
|
||||
<h4>Payment Method:</h4>
|
||||
<ul class="list-unstyled">
|
||||
<t t-set="payment_methods_available" t-value="False"/>
|
||||
<t t-set="partner_country" t-value="website_sale_order and website_sale_order.partner_invoice_id.country_id"/>
|
||||
<t t-foreach="acquirers or []" t-as="acquirer">
|
||||
<li>
|
||||
<li t-if="not acquirer.country_ids or partner_country in acquirer.country_ids">
|
||||
<label t-if="acquirer.button">
|
||||
<input t-att-value="acquirer.id" type="radio" name="acquirer" t-att-checked="acquirers[0] == acquirer" />
|
||||
<span t-field="acquirer.image_small" t-att-title="acquirer.name" t-field-options='{"widget": "image", "style":"max-width: 60px; display: inline-block"}'/>
|
||||
<span t-field="acquirer.name" />
|
||||
<span t-if="acquirer.fees_active">(processing fees apply)</span>
|
||||
</label>
|
||||
<t t-set="payment_methods_available" t-value="True"/>
|
||||
</li>
|
||||
</t>
|
||||
<li t-if="tokens">
|
||||
<li t-if="not payment_methods_available">
|
||||
<div class="alert alert-warning">
|
||||
<span>No payment gateway is available for your country</span>
|
||||
</div>
|
||||
</li>
|
||||
<li t-if="any(token for token in tokens if not token.acquirer_id.country_ids or partner_country in token.acquirer_id.country_ids)">
|
||||
<label>
|
||||
<input type="radio" name="acquirer" />
|
||||
<span class='fa fa-2x fa-credit-card'/>
|
||||
@@ -1360,7 +1368,7 @@
|
||||
|
||||
<div class="list-group">
|
||||
<t t-foreach='tokens' t-as='token'>
|
||||
<a class="list-group-item btn_payment_token" t-att-data-acquirer="token.acquirer_id.id" t-att-data-token='token.id'>
|
||||
<a t-if="not token.acquirer_id.country_ids or partner_country in token.acquirer_id.country_ids" class="list-group-item btn_payment_token" t-att-data-acquirer="token.acquirer_id.id" t-att-data-token='token.id'>
|
||||
<span class="js_radio fa fa-circle-o"></span>&nbsp;
|
||||
<t t-esc="token.name" />
|
||||
<t t-if="len(set(tokens.mapped('acquirer_id')))>1">
|
||||
|
||||
Reference in New Issue
Block a user