Skip to content
Snippets Groups Projects
Commit 8a9d7ddf 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#111982

X-original-commit: 5af4ffa9
Signed-off-by: default avatarTrinh Jacky (trj) <trj@odoo.com>
Signed-off-by: default avatarPedram Bi Ria (pebr) <pebr@odoo.com>
parent 6711a0ca
No related branches found
No related tags found
No related merge requests found
......@@ -146,6 +146,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
#: model:ir.model.fields,help:pos_adyen.field_pos_payment_method__adyen_api_key
msgid ""
......
......@@ -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