Skip to content
Snippets Groups Projects
Commit 5af4ffa9 authored by pedrambiria's avatar pedrambiria
Browse files

[FIX] pos_adyen: prevent having the same Adyen in multi-company


Before this commit: it was possible to create two PoS terminals in two
companies with the same `adyen_terminal_identifier`. So it's possible,
after each payment, it would add the response to the wrong payment
method's `adyen_latest_response`.

The solution is to bypass multi-company record rule in
`_check_adyen_terminal_identifier`.

opw-3131814

closes odoo/odoo#111483

X-original-commit: a9e4b1ad
Signed-off-by: default avatarTrinh Jacky (trj) <trj@odoo.com>
parent d68eafd5
No related branches found
No related tags found
No related merge requests found
......@@ -148,6 +148,12 @@ msgstr ""
msgid "Terminal %s is already used on payment method %s."
msgstr ""
#. module: pos_adyen
#: code:addons/pos_adyen/models/pos_payment_method.py:0
#, python-format
msgid "Terminal %s is already used in company %s on payment method %s."
msgstr ""
#. module: pos_adyen
#. openerp-web
#: code:addons/pos_adyen/static/src/js/payment_adyen.js:0
......
......@@ -32,12 +32,19 @@ class PosPaymentMethod(models.Model):
for payment_method in self:
if not payment_method.adyen_terminal_identifier:
continue
existing_payment_method = self.search([('id', '!=', payment_method.id),
# sudo() to search all companies
existing_payment_method = self.sudo().search([('id', '!=', payment_method.id),
('adyen_terminal_identifier', '=', payment_method.adyen_terminal_identifier)],
limit=1)
if existing_payment_method:
raise ValidationError(_('Terminal %s is already used on payment method %s.')
if existing_payment_method.company_id == payment_method.company_id:
raise ValidationError(_('Terminal %s is already used on payment method %s.')
% (payment_method.adyen_terminal_identifier, existing_payment_method.display_name))
else:
raise ValidationError(_('Terminal %s is already used in company %s on payment method %s.')
% (payment_method.adyen_terminal_identifier,
existing_payment_method.company_id.name,
existing_payment_method.display_name))
def _get_adyen_endpoints(self):
return {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment