Ensure payment instance has the right company context

The call to save restore the context when the record was instantiated.

issue8780
review256151003
This commit is contained in:
Cédric Krier committed 2019-11-01 23:01:43 +01:00
1 parent 3715b5cee8
commit 01cc8c4b41
1 file changed
+7
+7
View File
@@ -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']