From 01cc8c4b41ca441ae685a19e341d9903bfd0097d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 1 Nov 2019 23:01:43 +0100 Subject: [PATCH] Ensure payment instance has the right company context The call to save restore the context when the record was instantiated. issue8780 review256151003 --- payment.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/payment.py b/payment.py index 7c9c1174db..27155eb86b 100644 --- a/payment.py +++ b/payment.py @@ -857,6 +857,7 @@ class Account(ModelSQL, ModelView): for payment in payments: # TODO: remove when https://bugs.tryton.org/issue4080 with Transaction().set_context(company=payment.company.id): + payment = Payment(payment.id) if payment.state == 'succeeded': Payment.fail([payment]) payment.stripe_captured = charge['captured'] @@ -900,6 +901,7 @@ class Account(ModelSQL, ModelView): for payment in payments: # TODO: remove when https://bugs.tryton.org/issue4080 with Transaction().set_context(company=payment.company.id): + payment = Payment(payment.id) payment.stripe_error_message = charge['failure_message'] payment.stripe_error_code = charge['failure_code'] payment.stripe_error_param = None @@ -930,6 +932,7 @@ class Account(ModelSQL, ModelView): for payment in payments: # TODO: remove when https://bugs.tryton.org/issue4080 with Transaction().set_context(company=payment.company.id): + payment = Payment(payment.id) payment.stripe_dispute_reason = source['reason'] payment.stripe_dispute_status = source['status'] payment.save() @@ -957,6 +960,7 @@ class Account(ModelSQL, ModelView): for payment in payments: # TODO: remove when https://bugs.tryton.org/issue4080 with Transaction().set_context(company=payment.company.id): + payment = Payment(payment.id) payment.stripe_dispute_reason = source['reason'] payment.stripe_dispute_status = source['status'] payment.save() @@ -1023,6 +1027,7 @@ class Account(ModelSQL, ModelView): for payment in payments: # TODO: remove when https://bugs.tryton.org/issue4080 with Transaction().set_context(company=payment.company.id): + payment = Payment(payment.id) if payment.state == 'succeeded': Payment.fail([payment]) payment.stripe_captured = bool( @@ -1050,6 +1055,7 @@ class Account(ModelSQL, ModelView): for payment in payments: # TODO: remove when https://bugs.tryton.org/issue4080 with Transaction().set_context(company=payment.company.id): + payment = Payment(payment.id) if payment.state == 'succeeded': Payment.fail([payment]) payment.stripe_capturable = bool( @@ -1074,6 +1080,7 @@ class Account(ModelSQL, ModelView): for payment in payments: # TODO: remove when https://bugs.tryton.org/issue4080 with Transaction().set_context(company=payment.company.id): + payment = Payment(payment.id) error = payment_intent['last_payment_error'] if error: payment.stripe_error_message = error['message']