[REF] payment, *: make helper methods on portal private

*: account_payment, sale

This doesn't change anything from a technical point of view, but it
helps to consistently assess whether a method is attached to a route or
not, only by looking at the class' skeleton.

closes odoo/odoo#91359

X-original-commit: 93de42458ed0a7df20a7bc2f2c2b106386293c78
Related: odoo/enterprise#27330
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
This commit is contained in:
Antoine Vandevenne (anv)
2022-05-13 18:11:16 +02:00
parent 0574077999
commit fadff0cc91
3 changed files with 11 additions and 11 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ class PortalAccount(portal.PortalAccount):
# Make sure that the partner's company matches the invoice's company.
invoice_company = invoice.company_id or request.env.company
PaymentPortal.ensure_matching_companies(partner, invoice_company)
PaymentPortal._ensure_matching_companies(partner, invoice_company)
acquirers_sudo = request.env['payment.acquirer'].sudo()._get_compatible_acquirers(
invoice_company.id, partner.id, currency_id=invoice.currency_id.id
+7 -7
View File
@@ -68,9 +68,9 @@ class PaymentPortal(portal.CustomerPortal):
"""
# Cast numeric parameters as int or float and void them if their str value is malformed
currency_id, acquirer_id, partner_id, company_id, invoice_id = tuple(map(
self.cast_as_int, (currency_id, acquirer_id, partner_id, company_id, invoice_id)
self._cast_as_int, (currency_id, acquirer_id, partner_id, company_id, invoice_id)
))
amount = self.cast_as_float(amount)
amount = self._cast_as_float(amount)
# Raise an HTTP 404 if a partner is provided with an invalid access token
if partner_id:
@@ -104,7 +104,7 @@ class PaymentPortal(portal.CustomerPortal):
currency_id = currency_id or company.currency_id.id
# Make sure that the company passed as parameter matches the partner's company.
PaymentPortal.ensure_matching_companies(partner_sudo, company)
PaymentPortal._ensure_matching_companies(partner_sudo, company)
# Make sure that the currency exists and is active
currency = request.env['res.currency'].browse(currency_id).exists()
@@ -346,7 +346,7 @@ class PaymentPortal(portal.CustomerPortal):
:param dict kwargs: Optional data. This parameter is not used here
:raise: werkzeug.exceptions.NotFound if the access token is invalid
"""
tx_id = self.cast_as_int(tx_id)
tx_id = self._cast_as_int(tx_id)
if tx_id:
tx_sudo = request.env['payment.transaction'].sudo().browse(tx_id)
@@ -404,7 +404,7 @@ class PaymentPortal(portal.CustomerPortal):
token_sudo.active = False
@staticmethod
def cast_as_int(str_value):
def _cast_as_int(str_value):
""" Cast a string as an `int` and return it.
If the conversion fails, `None` is returned instead.
@@ -419,7 +419,7 @@ class PaymentPortal(portal.CustomerPortal):
return None
@staticmethod
def cast_as_float(str_value):
def _cast_as_float(str_value):
""" Cast a string as a `float` and return it.
If the conversion fails, `None` is returned instead.
@@ -434,7 +434,7 @@ class PaymentPortal(portal.CustomerPortal):
return None
@staticmethod
def ensure_matching_companies(partner, document_company):
def _ensure_matching_companies(partner, document_company):
""" Check that the partner's company is the same as the document's company.
If the partner company is not set, the check passes. If the companies don't match, a
+3 -3
View File
@@ -154,7 +154,7 @@ class CustomerPortal(portal.CustomerPortal):
logged_in = not request.env.user._is_public()
# Make sure that the partner's company matches the sales order's company.
payment_portal.PaymentPortal.ensure_matching_companies(
payment_portal.PaymentPortal._ensure_matching_companies(
order_sudo.partner_id, order_sudo.company_id
)
@@ -321,8 +321,8 @@ class PaymentPortal(payment_portal.PaymentPortal):
:raise: ValidationError if the order id is invalid
"""
# Cast numeric parameters as int or float and void them if their str value is malformed
amount = self.cast_as_float(amount)
sale_order_id = self.cast_as_int(sale_order_id)
amount = self._cast_as_float(amount)
sale_order_id = self._cast_as_int(sale_order_id)
if sale_order_id:
order_sudo = request.env['sale.order'].sudo().browse(sale_order_id).exists()
if not order_sudo: