diff options
| author | jev-odoo <jev@odoo.com> | 2019-10-25 06:47:13 +0000 |
|---|---|---|
| committer | jev-odoo <jev@odoo.com> | 2019-12-18 07:06:31 +0000 |
| commit | b308a173a68433ddc24aecabd8ffb84211998e75 (patch) | |
| tree | 06238ee766db81a6c1fb94f3f13cdca7d3fda020 /addons | |
| parent | 1f8706edd4c12e8381ffdb49ed0bf4e196c75166 (diff) | |
[FIX] payment_paypal: Less confusing transaction logs
Before this commit, the log displayed "set as done"
before actually trying to put the transaction in done.
If an error then occurred in the'_set_transaction_done'
function and the transaction could not be processed,
this could lead to a misinterpretation of these logs.
This log is therefore moved after the transaction is
processed and is only displayed if it is actually successful.
This is valid for'done','pending' and'cancel'.
closes odoo/odoo#42089
X-original-commit: dd7552b1a48020f3f48cd40a5fc1cbc4c38a7f90
Signed-off-by: jev <jev-odoo@users.noreply.github.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/payment_paypal/models/payment.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/addons/payment_paypal/models/payment.py b/addons/payment_paypal/models/payment.py index 40b38c70092..55d2935a190 100644 --- a/addons/payment_paypal/models/payment.py +++ b/addons/payment_paypal/models/payment.py @@ -184,6 +184,7 @@ class TxPaypal(models.Model): def _paypal_form_validate(self, data): status = data.get('payment_status') + former_tx_state = self.state res = { 'acquirer_reference': data.get('txn_id'), 'paypal_txn_type': data.get('payment_type'), @@ -205,7 +206,6 @@ class TxPaypal(models.Model): self.env['mail.mail'].sudo().create(mail_values).send() if status in ['Completed', 'Processed']: - _logger.info('Validated Paypal payment for tx %s: set as done' % (self.reference)) try: # dateutil and pytz don't recognize abbreviations PDT/PST tzinfos = { @@ -217,15 +217,22 @@ class TxPaypal(models.Model): date = fields.Datetime.now() res.update(date=date) self._set_transaction_done() - return self.write(res) + if self.state == 'done' and self.state != former_tx_state: + _logger.info('Validated Paypal payment for tx %s: set as done' % (self.reference)) + return self.write(res) + return True elif status in ['Pending', 'Expired']: - _logger.info('Received notification for Paypal payment %s: set as pending' % (self.reference)) res.update(state_message=data.get('pending_reason', '')) self._set_transaction_pending() - return self.write(res) + if self.state == 'pending' and self.state != former_tx_state: + _logger.info('Received notification for Paypal payment %s: set as pending' % (self.reference)) + return self.write(res) + return True else: error = 'Received unrecognized status for Paypal payment %s: %s, set as error' % (self.reference, status) - _logger.info(error) res.update(state_message=error) self._set_transaction_cancel() - return self.write(res) + if self.state == 'cancel' and self.state != former_tx_state: + _logger.info(error) + return self.write(res) + return True |
