[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#112080 X-original-commit: 8a9d7ddf0739b3f7c3224f53f7593be40be0b15a Signed-off-by: Trinh Jacky (trj) <trj@odoo.com> Signed-off-by: Pedram Bi Ria (pebr) <pebr@odoo.com>
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user