[FIX] payment, *: re-use the partner of the document
*: account_payment, sale, website_payment, website_payment opw-3097856 closes odoo/odoo#109695 X-original-commit: a452221c51f5659c88cb479ded192a2ad395e7d6 Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
This commit is contained in:
@@ -24,13 +24,16 @@ class PaymentPortal(payment_portal.PaymentPortal):
|
||||
"""
|
||||
# Check the invoice id and the access token
|
||||
try:
|
||||
self._document_check_access('account.move', invoice_id, access_token)
|
||||
invoice_sudo = self._document_check_access('account.move', invoice_id, access_token)
|
||||
except MissingError as error:
|
||||
raise error
|
||||
except AccessError:
|
||||
raise ValidationError(_("The access token is invalid."))
|
||||
|
||||
kwargs['reference_prefix'] = None # Allow the reference to be computed based on the invoice
|
||||
logged_in = not request.env.user._is_public()
|
||||
partner = request.env.user.partner_id if logged_in else invoice_sudo.partner_id
|
||||
kwargs['partner_id'] = partner.id
|
||||
kwargs.pop('custom_create_values', None) # Don't allow passing arbitrary create values
|
||||
tx_sudo = self._create_transaction(
|
||||
custom_create_values={'invoice_ids': [Command.set([invoice_id])]}, **kwargs,
|
||||
|
||||
@@ -301,7 +301,7 @@ class PaymentPortal(payment_portal.PaymentPortal):
|
||||
"""
|
||||
# Check the order id and the access token
|
||||
try:
|
||||
self._document_check_access('sale.order', order_id, access_token)
|
||||
order_sudo = self._document_check_access('sale.order', order_id, access_token)
|
||||
except MissingError as error:
|
||||
raise error
|
||||
except AccessError:
|
||||
@@ -309,6 +309,7 @@ class PaymentPortal(payment_portal.PaymentPortal):
|
||||
|
||||
kwargs.update({
|
||||
'reference_prefix': None, # Allow the reference to be computed based on the order
|
||||
'partner_id': order_sudo.partner_id.id,
|
||||
'sale_order_id': order_id, # Include the SO to allow Subscriptions tokenizing the tx
|
||||
})
|
||||
kwargs.pop('custom_create_values', None) # Don't allow passing arbitrary create values
|
||||
|
||||
@@ -61,6 +61,8 @@ class PaymentPortal(payment_portal.PaymentPortal):
|
||||
raise ValidationError(_('Country is required.'))
|
||||
partner_id = request.website.user_id.partner_id.id
|
||||
del kwargs['partner_details']
|
||||
else:
|
||||
partner_id = request.env.user.partner_id.id
|
||||
|
||||
kwargs.pop('custom_create_values', None) # Don't allow passing arbitrary create values
|
||||
tx_sudo = self._create_transaction(
|
||||
|
||||
@@ -1734,6 +1734,7 @@ class PaymentPortal(payment_portal.PaymentPortal):
|
||||
|
||||
kwargs.update({
|
||||
'reference_prefix': None, # Allow the reference to be computed based on the order
|
||||
'partner_id': order_sudo.partner_id.id,
|
||||
'sale_order_id': order_id, # Include the SO to allow Subscriptions to tokenize the tx
|
||||
})
|
||||
kwargs.pop('custom_create_values', None) # Don't allow passing arbitrary create values
|
||||
|
||||
Reference in New Issue
Block a user