summaryrefslogtreecommitdiff
path: root/addons/payment/models/payment_acquirer.py
diff options
context:
space:
mode:
authorAdrian Torres <adt@odoo.com>2019-07-10 14:59:37 +0200
committerAdrian Torres <adt@odoo.com>2019-07-17 14:13:12 +0200
commit4b38cc6590abcb58a0ca102a06063eb3db7ac1f4 (patch)
treecfd11739fc6b4c0cb4b23b54cc6badad4bf5c55e /addons/payment/models/payment_acquirer.py
parentf6fdde96bddfedf8764cd8a73089e44340d476ae (diff)
[REM] *: calls to @api.multi
Multi is the default api for methods, it is not necessary to explicitly decorate methods with it, adds clutter and most people use it because they see that the rest of the code uses it. Done with `find . -type f -name '*.py' | xargs sed -i '/@api.multi/d'`
Diffstat (limited to 'addons/payment/models/payment_acquirer.py')
-rw-r--r--addons/payment/models/payment_acquirer.py38
1 files changed, 0 insertions, 38 deletions
diff --git a/addons/payment/models/payment_acquirer.py b/addons/payment/models/payment_acquirer.py
index 7b747de0ce6..2ae15c91fb9 100644
--- a/addons/payment/models/payment_acquirer.py
+++ b/addons/payment/models/payment_acquirer.py
@@ -187,7 +187,6 @@ class PaymentAcquirer(models.Model):
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:
@@ -195,7 +194,6 @@ class PaymentAcquirer(models.Model):
acquirer.authorize_implemented = acquirer.provider in feature_support['authorize']
acquirer.token_implemented = acquirer.provider in feature_support['tokenize']
- @api.multi
def _check_required_if_provider(self):
""" If the field has 'required_if_provider="<provider>"' attribute, then it
required if record.provider is <provider>. """
@@ -225,7 +223,6 @@ class PaymentAcquirer(models.Model):
"""
return dict(authorize=[], tokenize=[], fees=[])
- @api.multi
def _prepare_account_journal_vals(self):
'''Prepare the values to create the acquirer's journal.
:return: a dictionary to create a account.journal record.
@@ -282,12 +279,10 @@ class PaymentAcquirer(models.Model):
image_resize_images(vals)
return super(PaymentAcquirer, self).create(vals)
- @api.multi
def write(self, vals):
image_resize_images(vals)
return super(PaymentAcquirer, self).write(vals)
- @api.multi
def toggle_website_published(self):
''' When clicking on the website publish toggle button, the website_published is reversed and
the acquirer journal is set or not in favorite on the dashboard.
@@ -298,7 +293,6 @@ class PaymentAcquirer(models.Model):
self.journal_id.show_on_dashboard = self.website_published
return True
- @api.multi
def get_acquirer_extra_fees(self, amount, currency_id, country_id):
extra_fees = {
'currency_id': currency_id
@@ -311,7 +305,6 @@ class PaymentAcquirer(models.Model):
extra_fees[acq] = fees
return extra_fees
- @api.multi
def get_form_action_url(self):
""" Returns the form action URL, for form-based acquirer implementations. """
if hasattr(self, '%s_get_form_action_url' % self.provider):
@@ -341,7 +334,6 @@ class PaymentAcquirer(models.Model):
('acquirer_id', 'in', acquirers.ids)]),
}
- @api.multi
def render(self, reference, amount, currency_id, partner_id=False, values=None):
""" Renders the form template of the given acquirer as a qWeb template.
:param string reference: the transaction reference
@@ -475,7 +467,6 @@ class PaymentAcquirer(models.Model):
return ('%s.%s') % (model_data.module, model_data.name)
return False
- @api.multi
def s2s_process(self, data):
cust_method_name = '%s_s2s_form_process' % (self.provider)
if not self.s2s_validate(data):
@@ -489,7 +480,6 @@ class PaymentAcquirer(models.Model):
return method(data)
return True
- @api.multi
def s2s_validate(self, data):
cust_method_name = '%s_s2s_form_validate' % (self.provider)
if hasattr(self, cust_method_name):
@@ -497,13 +487,11 @@ class PaymentAcquirer(models.Model):
return method(data)
return True
- @api.multi
def toggle_environment_value(self):
prod = self.filtered(lambda acquirer: acquirer.environment == 'prod')
prod.write({'environment': 'test'})
(self-prod).write({'environment': 'prod'})
- @api.multi
def button_immediate_install(self):
# TDE FIXME: remove that brol
if self.module_id and self.module_state != 'installed':
@@ -534,7 +522,6 @@ class PaymentIcon(models.Model):
vals['image'] = image_process(image, size=(64,64))
return super(PaymentIcon, self).create(vals_list)
- @api.multi
def write(self, vals):
if 'image' in vals:
image = ustr(vals['image'] or '').encode('utf-8')
@@ -638,7 +625,6 @@ class PaymentTransaction(models.Model):
for trans in self:
trans.invoice_ids_nbr = len(trans.invoice_ids)
- @api.multi
def _prepare_account_payment_vals(self):
self.ensure_one()
return {
@@ -656,12 +642,10 @@ class PaymentTransaction(models.Model):
'communication': self.reference,
}
- @api.multi
def get_last_transaction(self):
transactions = self.filtered(lambda t: t.state != 'draft')
return transactions and transactions[0] or transactions
- @api.multi
def _get_payment_transaction_sent_message(self):
self.ensure_one()
if self.payment_token_id:
@@ -677,7 +661,6 @@ class PaymentTransaction(models.Model):
message += ' ' + _('Waiting for payment confirmation...')
return message % message_vals
- @api.multi
def _get_payment_transaction_received_message(self):
self.ensure_one()
amount = formatLang(self.env, self.amount, currency_obj=self.currency_id)
@@ -699,7 +682,6 @@ class PaymentTransaction(models.Model):
message = _('The transaction %s with %s for %s has been cancelled.')
return message % tuple(message_vals)
- @api.multi
def _log_payment_transaction_sent(self):
'''Log the message saying the transaction has been sent to the remote server to be
processed by the acquirer.
@@ -709,7 +691,6 @@ class PaymentTransaction(models.Model):
for inv in trans.invoice_ids:
inv.message_post(body=post_message)
- @api.multi
def _log_payment_transaction_received(self):
'''Log the message saying a response has been received from the remote server and some
additional informations like the old/new state, the reference of the payment... etc.
@@ -721,7 +702,6 @@ class PaymentTransaction(models.Model):
for inv in trans.invoice_ids:
inv.message_post(body=post_message)
- @api.multi
def _set_transaction_pending(self):
'''Move the transaction to the pending state(e.g. Wire Transfer).'''
if any(trans.state != 'draft' for trans in self):
@@ -730,7 +710,6 @@ class PaymentTransaction(models.Model):
self.write({'state': 'pending', 'date': datetime.now().strftime(DEFAULT_SERVER_DATETIME_FORMAT)})
self._log_payment_transaction_received()
- @api.multi
def _set_transaction_authorized(self):
'''Move the transaction to the authorized state(e.g. Authorize).'''
if any(trans.state != 'draft' for trans in self):
@@ -739,7 +718,6 @@ class PaymentTransaction(models.Model):
self.write({'state': 'authorized', 'date': datetime.now().strftime(DEFAULT_SERVER_DATETIME_FORMAT)})
self._log_payment_transaction_received()
- @api.multi
def _set_transaction_done(self):
'''Move the transaction's payment to the done state(e.g. Paypal).'''
if any(trans.state not in ('draft', 'authorized', 'pending') for trans in self):
@@ -747,7 +725,6 @@ class PaymentTransaction(models.Model):
self.write({'state': 'done', 'date': datetime.now().strftime(DEFAULT_SERVER_DATETIME_FORMAT)})
- @api.multi
def _reconcile_after_transaction_done(self):
# Validate invoices automatically upon the transaction is posted.
invoices = self.mapped('invoice_ids').filtered(lambda inv: inv.state == 'draft')
@@ -770,7 +747,6 @@ class PaymentTransaction(models.Model):
for company in payments:
payments[company].with_context(force_company=company, company_id=company).post()
- @api.multi
def _set_transaction_cancel(self):
'''Move the transaction's payment to the cancel state(e.g. Paypal).'''
if any(trans.state not in ('draft', 'authorized') for trans in self):
@@ -782,7 +758,6 @@ class PaymentTransaction(models.Model):
self.write({'state': 'cancel', 'date': datetime.now().strftime(DEFAULT_SERVER_DATETIME_FORMAT)})
self._log_payment_transaction_received()
- @api.multi
def _set_transaction_error(self, msg):
'''Move the transaction to the error state (Third party returning error e.g. Paypal).'''
if any(trans.state != 'draft' for trans in self):
@@ -795,14 +770,12 @@ class PaymentTransaction(models.Model):
})
self._log_payment_transaction_received()
- @api.multi
def _post_process_after_done(self):
self._reconcile_after_transaction_done()
self._log_payment_transaction_received()
self.write({'is_processed': True})
return True
- @api.multi
def _cron_post_process_after_done(self):
if not self:
ten_minutes_ago = datetime.now() - relativedelta.relativedelta(minutes=10)
@@ -866,7 +839,6 @@ class PaymentTransaction(models.Model):
return '%s-%s' % (prefix, suffix)
- @api.multi
def action_view_invoices(self):
action = {
'name': _('Invoices'),
@@ -978,7 +950,6 @@ class PaymentTransaction(models.Model):
# SERVER2SERVER RELATED METHODS
# --------------------------------------------------
- @api.multi
def s2s_do_transaction(self, **kwargs):
custom_method_name = '%s_s2s_do_transaction' % self.acquirer_id.provider
for trans in self:
@@ -986,25 +957,21 @@ class PaymentTransaction(models.Model):
if hasattr(trans, custom_method_name):
return getattr(trans, custom_method_name)(**kwargs)
- @api.multi
def s2s_do_refund(self, **kwargs):
custom_method_name = '%s_s2s_do_refund' % self.acquirer_id.provider
if hasattr(self, custom_method_name):
return getattr(self, custom_method_name)(**kwargs)
- @api.multi
def s2s_capture_transaction(self, **kwargs):
custom_method_name = '%s_s2s_capture_transaction' % self.acquirer_id.provider
if hasattr(self, custom_method_name):
return getattr(self, custom_method_name)(**kwargs)
- @api.multi
def s2s_void_transaction(self, **kwargs):
custom_method_name = '%s_s2s_void_transaction' % self.acquirer_id.provider
if hasattr(self, custom_method_name):
return getattr(self, custom_method_name)(**kwargs)
- @api.multi
def s2s_get_tx_status(self):
""" Get the tx status. """
invalid_param_method_name = '_%s_s2s_get_tx_status' % self.acquirer_id.provider
@@ -1012,7 +979,6 @@ class PaymentTransaction(models.Model):
return getattr(self, invalid_param_method_name)()
return True
- @api.multi
def execute_callback(self):
res = None
for transaction in self:
@@ -1034,14 +1000,12 @@ class PaymentTransaction(models.Model):
_logger.warning("Did not found record %s.%s for callback of transaction %d" % (transaction.callback_model_id.model, transaction.callback_res_id, transaction.id))
return res
- @api.multi
def action_capture(self):
if any([t.state != 'authorized' for t in self]):
raise ValidationError(_('Only transactions having the capture status can be captured.'))
for tx in self:
tx.s2s_capture_transaction()
- @api.multi
def action_void(self):
if any([t.state != 'authorized' for t in self]):
raise ValidationError(_('Only transactions having the capture status can be voided.'))
@@ -1147,13 +1111,11 @@ class PaymentToken(models.Model):
return tx
- @api.multi
@api.depends('name')
def _compute_short_name(self):
for token in self:
token.short_name = token.name.replace('XXXXXXXXXXXX', '***')
- @api.multi
def get_linked_records(self):
""" This method returns a dict containing all the records linked to the payment.token (e.g Subscriptions),
the key is the id of the payment.token and the value is an array that must follow the scheme below.