-
-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] *_import[_online]_adyen: adapt to 16.0
- Loading branch information
Showing
19 changed files
with
150 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from . import models | ||
from . import wizards |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
# Copyright 2017 Opener BV <https://opener.amsterdam> | ||
# Copyright 2020 Vanmoof BV <https://www.vanmoof.com> | ||
# Copyright 2021 Therp BV <https://therp.nl>. | ||
# Copyright 2021-2023 Therp BV <https://therp.nl>. | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "Adyen statement import", | ||
"version": "13.0.1.0.0", | ||
"author": "Opener BV, Vanmoof BV, Odoo Community Association (OCA)", | ||
"version": "16.0.1.0.0", | ||
"author": "Opener BV, Vanmoof BV, Therp BV, Odoo Community Association (OCA)", | ||
"category": "Banking addons", | ||
"website": "https://github.com/OCA/bank-statement-import", | ||
"license": "AGPL-3", | ||
"depends": [ | ||
"base_import", | ||
"account_bank_statement_import", | ||
"account_bank_statement_clearing_account", | ||
"account_statement_import_file", | ||
"account_statement_clearing_account", | ||
], | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"views/account_journal.xml", | ||
], | ||
"data": ["views/account_journal.xml"], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
from . import account_bank_statement_import | ||
from . import account_bank_statement_import_adyen_parser | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from . import account_journal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_account_statement_import_adyen_parser,access_account_statement_import_adyen_parser,model_account_statement_import_adyen_parser,base.group_user,1,0,0,0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from . import account_statement_import | ||
from . import account_statement_import_adyen_parser |
33 changes: 21 additions & 12 deletions
33
...n/models/account_bank_statement_import.py → ...adyen/wizards/account_statement_import.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,56 @@ | ||
# Copyright 2017 Opener BV (<https://opener.amsterdam>) | ||
# Copyright 2021-2022 Therp BV <https://therp.nl>. | ||
# Copyright 2021-2023 Therp BV <https://therp.nl>. | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
"""Add import of Adyen statements.""" | ||
# pylint: disable=protected-access,no-self-use | ||
import logging | ||
|
||
from odoo import _, models | ||
from odoo.exceptions import UserError | ||
|
||
_logger = logging.getLogger(__name__) # pylint: disable=invalid-name | ||
|
||
|
||
class AccountBankStatementImport(models.TransientModel): | ||
class AccountStatementImport(models.TransientModel): | ||
"""Add import of Adyen statements.""" | ||
|
||
_inherit = "account.bank.statement.import" | ||
_inherit = "account.statement.import" | ||
|
||
def _parse_file(self, data_file): | ||
"""Parse an Adyen xlsx file and map merchant account strings to journals.""" | ||
try: | ||
return self._parse_adyen_file(data_file) | ||
except Exception as exc: # pylint: disable=broad-except | ||
message = _("Statement file was not a Adyen settlement details file.") | ||
if self.env.context.get("account_bank_statement_import_adyen", False): | ||
raise UserError(message) from exc | ||
message = ( | ||
_("Statement file %s was not a Adyen settlement details file.") | ||
% self.statement_filename | ||
or "* no filename *" | ||
) | ||
if self.env.context.get("account_statement_import_adyen", False): | ||
raise ValueError(message) from exc | ||
_logger.debug(message, exc_info=True) | ||
return super()._parse_file(data_file) | ||
|
||
def _parse_adyen_file(self, data_file): | ||
"""Just parse the adyen file.""" | ||
_logger.debug(_("Try parsing as Adyen settlement details.")) | ||
parser = self.env["account.bank.statement.import.adyen.parser"] | ||
parser = self.env["account.statement.import.adyen.parser"] | ||
rows = self._get_rows(data_file) | ||
return parser.parse_rows(rows) | ||
|
||
def _get_rows(self, data_file): | ||
"""Get rows from data_file.""" | ||
# Try to use original import file name. | ||
filename = ( | ||
self.attachment_ids[0].name | ||
if len(self.attachment_ids) == 1 | ||
self.statement_filename | ||
if self.statement_filename | ||
else "Ayden settlement details" | ||
) | ||
import_model = self.env["base_import.import"] | ||
importer = import_model.create({"file": data_file, "file_name": filename}) | ||
return importer._read_file({"quoting": '"', "separator": ","}) | ||
importer = import_model.create( | ||
{ | ||
"file": data_file, | ||
"file_name": filename, | ||
} | ||
) | ||
_num_rows, rows = importer._read_file({"quoting": '"', "separator": ","}) | ||
return rows |
Oops, something went wrong.