summaryrefslogtreecommitdiff
path: root/addons/payment/models
diff options
context:
space:
mode:
authorRobot Odoo <xmo+roboto@odoo.com>2019-07-17 14:17:57 +0200
committerGitHub <noreply@github.com>2019-07-17 14:17:57 +0200
commitcc62447a44c2cf4e2edaf8a1f6d94520e799ddd9 (patch)
treea45f0984af5db1723fec83741b285ea92ab63598 /addons/payment/models
parentf6fdde96bddfedf8764cd8a73089e44340d476ae (diff)
parenta8767716cfd14abc7f87204d4d180811f663b648 (diff)
[MERGE] api.py: remove calls to @api.multi and deprecate its explicit usage
depends on https://github.com/odoo/odoo/pull/34556 closes odoo/odoo#34775 Signed-off-by: Adrian Torres <Elkasitu@users.noreply.github.com>
Diffstat (limited to 'addons/payment/models')
-rw-r--r--addons/payment/models/account_invoice.py4
-rw-r--r--addons/payment/models/account_payment.py4
-rw-r--r--addons/payment/models/chart_template.py1
-rw-r--r--addons/payment/models/payment_acquirer.py38
4 files changed, 0 insertions, 47 deletions
diff --git a/addons/payment/models/account_invoice.py b/addons/payment/models/account_invoice.py
index de16fb595c8..882a25b6279 100644
--- a/addons/payment/models/account_invoice.py
+++ b/addons/payment/models/account_invoice.py
@@ -18,12 +18,10 @@ class AccountMove(models.Model):
for trans in self:
trans.authorized_transaction_ids = trans.transaction_ids.filtered(lambda t: t.state == 'authorized')
- @api.multi
def get_portal_last_transaction(self):
self.ensure_one()
return self.transaction_ids.get_last_transaction()
- @api.multi
def _create_payment_transaction(self, vals):
'''Similar to self.env['payment.transaction'].create(vals) but the values are filled with the
current invoices fields (e.g. the partner or the currency).
@@ -89,10 +87,8 @@ class AccountMove(models.Model):
return transaction
- @api.multi
def payment_action_capture(self):
self.authorized_transaction_ids.s2s_capture_transaction()
- @api.multi
def payment_action_void(self):
self.authorized_transaction_ids.s2s_void_transaction()
diff --git a/addons/payment/models/account_payment.py b/addons/payment/models/account_payment.py
index 220cb37db38..fe6f31eeb21 100644
--- a/addons/payment/models/account_payment.py
+++ b/addons/payment/models/account_payment.py
@@ -13,7 +13,6 @@ class AccountPayment(models.Model):
payment_token_id = fields.Many2one('payment.token', string="Saved payment token", domain=[('acquirer_id.capture_manually', '=', False)],
help="Note that tokens from acquirers set to only authorize transactions (instead of capturing the amount) are not available.")
- @api.multi
def _get_payment_chatter_link(self):
self.ensure_one()
return '<a href=# data-oe-model=account.payment data-oe-id=%d>%s</a>' % (self.id, self.name)
@@ -33,7 +32,6 @@ class AccountPayment(models.Model):
res['domain'] = {'payment_token_id': domain}
return res
- @api.multi
def _prepare_payment_transaction_vals(self):
self.ensure_one()
return {
@@ -48,7 +46,6 @@ class AccountPayment(models.Model):
'type': 'server2server',
}
- @api.multi
def _create_payment_transaction(self, vals=None):
for pay in self:
if pay.payment_transaction_id:
@@ -76,7 +73,6 @@ class AccountPayment(models.Model):
self.mapped('payment_transaction_id').filtered(lambda x: x.state == 'done' and not x.is_processed)._post_process_after_done()
return res
- @api.multi
def post(self):
# Post the payments "normally" if no transactions are needed.
# If not, let the acquirer updates the state.
diff --git a/addons/payment/models/chart_template.py b/addons/payment/models/chart_template.py
index ddf814d7d93..0e7ef826c13 100644
--- a/addons/payment/models/chart_template.py
+++ b/addons/payment/models/chart_template.py
@@ -6,7 +6,6 @@ from odoo import api, fields, models, _
class AccountChartTemplate(models.Model):
_inherit = 'account.chart.template'
- @api.multi
def _create_bank_journals(self, company, acc_template_ref):
res = super(AccountChartTemplate, self)._create_bank_journals(company, acc_template_ref)
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.