summaryrefslogtreecommitdiff
path: root/addons/payment/models
diff options
context:
space:
mode:
authorElkasitu <adt@odoo.com>2017-05-11 12:38:21 +0200
committerDamien Bouvy <dbo@odoo.com>2017-07-07 20:06:41 +0200
commit0e39cc934574fdd7e1c540d89f243260e190f77a (patch)
tree9b5d80450bae61c40835e519a144bbf89f02b3fb /addons/payment/models
parent182c8d2815dafead5a8f72fcd90efbe69a182eb7 (diff)
[IMP] payment: Add search for token_implemented
Since subscriptions only accept tokenizable (credit-cards and such) payment options, we must use the token_implemented field to filter out non-tokenizable payment options (such as wire transfer) and because token_implemented is a computed field, a search function had to be created
Diffstat (limited to 'addons/payment/models')
-rw-r--r--addons/payment/models/payment_acquirer.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/addons/payment/models/payment_acquirer.py b/addons/payment/models/payment_acquirer.py
index 2f3fc969458..4777cbc8318 100644
--- a/addons/payment/models/payment_acquirer.py
+++ b/addons/payment/models/payment_acquirer.py
@@ -122,7 +122,7 @@ class PaymentAcquirer(models.Model):
help="This option allows customers to save their credit card as a payment token and to reuse it for a later purchase."
"If you manage subscriptions (recurring invoicing), you need it to automatically charge the customer when you "
"issue an invoice.")
- token_implemented = fields.Boolean('Saving Card Data supported', compute='_compute_feature_support')
+ token_implemented = fields.Boolean('Saving Card Data supported', compute='_compute_feature_support', search='_search_is_tokenized')
authorize_implemented = fields.Boolean('Authorize Mechanism Supported', compute='_compute_feature_support')
fees_implemented = fields.Boolean('Fees Computation Supported', compute='_compute_feature_support')
fees_active = fields.Boolean('Add Extra Fees')
@@ -149,6 +149,13 @@ class PaymentAcquirer(models.Model):
"resized as a 64x64px image, with aspect ratio preserved. "
"Use this field anywhere a small image is required.")
+ def _search_is_tokenized(self, operator, value):
+ tokenized = self._get_feature_support()['tokenize']
+ if (operator, value) in [('=', True), ('!=', False)]:
+ return [('provider', 'in', tokenized)]
+ return [('provider', 'not in', tokenized)]
+
+ @api.multi
def _compute_feature_support(self):
feature_support = self._get_feature_support()
for acquirer in self: