Skip to content

Commit

Permalink
[IMP] Adopt translation method
Browse files Browse the repository at this point in the history
  • Loading branch information
bosd committed Mar 17, 2024
1 parent 4add2d0 commit 41ceb86
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion payment_monero/controllers/monero_controller.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

from odoo import http
from odoo import http, _
from odoo.addons.payment.controllers.portal import PaymentProcessing
from odoo.http import request
from monero.address import SubAddress
Expand Down
16 changes: 8 additions & 8 deletions payment_monero/controllers/website_sale.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

from odoo import http
from odoo import http, _
from odoo.addons.website_sale.controllers.main import WebsiteSale
from odoo.exceptions import ValidationError, UserError

Expand Down Expand Up @@ -58,36 +58,36 @@ def payment(self, **post):
"can't authenticate with RPC "
"due to user name or password"
)
raise ValidationError(
raise ValidationError(_(
"Current technical issues "
"prevent Monero from being accepted, "
"choose another payment method"
)
))
except MoneroPaymentAcquirerRPCSSLError:
_logger.error(
"USER IMPACT: Monero Payment Acquirer "
"experienced an SSL Error with RPC"
)
raise ValidationError(
raise ValidationError(_(
"Current technical issues "
"prevent Monero from being accepted, "
"choose another payment method"
)
))
except (requests.exceptions.ConnectionError, requests.exceptions.Timeout, requests.exceptions.HTTPError) as e:
_logger.error('Monero RPC connection issue: %s', e)
except (urllib3.exceptions.HTTPError, urllib3.exceptions.NewConnectionError, urllib3.exceptions.MaxRetryError) as e:
_logger.error('connection error urllib3: %s', e)
raise UserError('urllib3 connection error.')
raise UserError(_('urllib3 connection error.'))
except Exception as e:
_logger.error(
"USER IMPACT: Monero Payment Acquirer "
"experienced an Error with RPC: {e.__class__.__name__} %s", e
)
# raise ValidationError(
# raise ValidationError(_(
# "Current technical issues "
# "prevent Monero from being accepted, "
# "choose another payment method"
#)
#))
return None

if render_values["errors"]:
Expand Down
18 changes: 9 additions & 9 deletions pos_payment_monero/controllers/monero_controller.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

from odoo.http import request
from odoo import http
from odoo import http, _
from odoo.exceptions import ValidationError

from monero.backends.jsonrpc import Unauthorized
Expand Down Expand Up @@ -65,31 +65,31 @@ def get_address(self, **kwargs):
"can't authenticate with RPC "
"due to user name or password"
)
raise ValidationError(
raise ValidationError(_(
"Current technical issues "
"prevent Monero from being accepted, "
"choose another payment method"
)
))
except MoneroPaymentMethodRPCSSLError:
_logger.error(
"USER IMPACT: Monero POS Payment Method "
"experienced an SSL Error with RPC"
)
raise ValidationError(
raise ValidationError(_(
"Current technical issues "
"prevent Monero from being accepted, "
"choose another payment method"
)
))
except Exception as e:
_logger.error(
f"USER IMPACT: Monero POS Payment Method "
f"experienced an Error with RPC: {e.__class__.__name__}"
)
raise ValidationError(
raise ValidationError(_(
"Current technical issues "
"prevent Monero from being accepted, "
"choose another payment method"
)
))

res = {
"wallet_address": wallet.new_address()[0],
Expand All @@ -99,10 +99,10 @@ def get_address(self, **kwargs):
"USER IMPACT: Monero POS Payment Method"
"experienced an Error with payment method: Not Found"
)
raise ValidationError(
raise ValidationError(_(
"Current technical issues "
"prevent Monero from being accepted, "
"choose another payment method"
)
))

return res

0 comments on commit 41ceb86

Please sign in to comment.