mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
[MIG]account_statement_import_paypal: Migration to 15.0
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
{
|
||||
"name": "PayPal CSV Format Bank Statements Import",
|
||||
"summary": "Import PayPal CSV files as Bank Statements in Odoo",
|
||||
"version": "14.0.1.0.0",
|
||||
"version": "15.0.1.0.0",
|
||||
"category": "Accounting",
|
||||
"website": "https://github.com/OCA/bank-statement-import",
|
||||
"author": "Akretion, CorporateHub, Odoo Community Association (OCA)",
|
||||
|
||||
@@ -23,6 +23,9 @@ class AccountStatementImport(models.TransientModel):
|
||||
self.ensure_one()
|
||||
try:
|
||||
Parser = self.env["account.statement.import.paypal.parser"]
|
||||
logging.warning(
|
||||
Parser.parse(self.paypal_mapping_id, data_file, self.statement_filename)
|
||||
)
|
||||
return Parser.parse(
|
||||
self.paypal_mapping_id, data_file, self.statement_filename
|
||||
)
|
||||
|
||||
@@ -26,11 +26,9 @@ class AccountBankStatementImportPayPalMapping(models.Model):
|
||||
required=True,
|
||||
)
|
||||
date_format = fields.Char(
|
||||
string="Date Format",
|
||||
required=True,
|
||||
)
|
||||
time_format = fields.Char(
|
||||
string="Time Format",
|
||||
required=True,
|
||||
)
|
||||
date_column = fields.Char(
|
||||
|
||||
@@ -38,10 +38,10 @@ class AccountBankStatementImportPayPalParser(models.TransientModel):
|
||||
currency_code = (journal.currency_id or journal.company_id.currency_id).name
|
||||
account_number = journal.bank_account_id.acc_number
|
||||
|
||||
name = _("%s: %s") % (
|
||||
journal.code,
|
||||
path.basename(filename),
|
||||
)
|
||||
name = _("%(code)s: %(path)s") % {
|
||||
"code": journal.code,
|
||||
"path": path.basename(filename),
|
||||
}
|
||||
lines = self._parse_lines(mapping, data_file, currency_code)
|
||||
if not lines:
|
||||
return currency_code, account_number, [{"name": name, "transactions": []}]
|
||||
|
||||
@@ -7,3 +7,4 @@
|
||||
* Carlos Roca
|
||||
|
||||
* Alexey Pelykh <alexey.pelykh@corphub.eu> (`CorporateHub <https://corporatehub.eu/>`__)
|
||||
* Manuel Regidor <manuel.regidor@sygel.es>
|
||||
|
||||
@@ -36,6 +36,7 @@ class TestAccountBankStatementImportPayPal(common.TransactionCase):
|
||||
self.AccountStatementImportPayPalMappingWizard = self.env[
|
||||
"account.statement.import.paypal.mapping.wizard"
|
||||
]
|
||||
self.env.ref("base.EUR").write({"active": True})
|
||||
|
||||
def _data_file(self, filename):
|
||||
with open(path.join(path.dirname(__file__), filename)) as file:
|
||||
@@ -50,9 +51,7 @@ class TestAccountBankStatementImportPayPal(common.TransactionCase):
|
||||
"currency_id": self.currency_usd.id,
|
||||
}
|
||||
)
|
||||
wizard = self.AccountStatementImport.with_context(
|
||||
{"journal_id": journal.id}
|
||||
).create(
|
||||
wizard = self.AccountStatementImport.with_context(journal_id=journal.id).create(
|
||||
{
|
||||
"statement_filename": "fixtures/statement_en.csv",
|
||||
"statement_file": self._data_file("fixtures/statement_en.csv"),
|
||||
@@ -60,10 +59,8 @@ class TestAccountBankStatementImportPayPal(common.TransactionCase):
|
||||
}
|
||||
)
|
||||
wizard.with_context(
|
||||
{
|
||||
"journal_id": journal.id,
|
||||
"account_statement_import_paypal_test": True,
|
||||
}
|
||||
journal_id=journal.id,
|
||||
account_statement_import_paypal_test=True,
|
||||
).import_file_button()
|
||||
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
||||
self.assertEqual(len(statement), 1)
|
||||
@@ -78,9 +75,7 @@ class TestAccountBankStatementImportPayPal(common.TransactionCase):
|
||||
"currency_id": self.currency_eur.id,
|
||||
}
|
||||
)
|
||||
wizard = self.AccountStatementImport.with_context(
|
||||
{"journal_id": journal.id}
|
||||
).create(
|
||||
wizard = self.AccountStatementImport.with_context(journal_id=journal.id).create(
|
||||
{
|
||||
"statement_filename": "fixtures/statement_en.csv",
|
||||
"statement_file": self._data_file("fixtures/statement_en.csv"),
|
||||
@@ -88,10 +83,8 @@ class TestAccountBankStatementImportPayPal(common.TransactionCase):
|
||||
}
|
||||
)
|
||||
wizard.with_context(
|
||||
{
|
||||
"journal_id": journal.id,
|
||||
"account_statement_import_paypal_test": True,
|
||||
}
|
||||
journal_id=journal.id,
|
||||
account_statement_import_paypal_test=True,
|
||||
).import_file_button()
|
||||
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
||||
self.assertEqual(len(statement), 1)
|
||||
@@ -106,9 +99,7 @@ class TestAccountBankStatementImportPayPal(common.TransactionCase):
|
||||
"currency_id": self.currency_eur.id,
|
||||
}
|
||||
)
|
||||
wizard = self.AccountStatementImport.with_context(
|
||||
{"journal_id": journal.id}
|
||||
).create(
|
||||
wizard = self.AccountStatementImport.with_context(journal_id=journal.id).create(
|
||||
{
|
||||
"statement_filename": "fixtures/statement_es.csv",
|
||||
"statement_file": self._data_file("fixtures/statement_es.csv"),
|
||||
@@ -116,10 +107,8 @@ class TestAccountBankStatementImportPayPal(common.TransactionCase):
|
||||
}
|
||||
)
|
||||
wizard.with_context(
|
||||
{
|
||||
"journal_id": journal.id,
|
||||
"account_statement_import_paypal_test": True,
|
||||
}
|
||||
journal_id=journal.id,
|
||||
account_statement_import_paypal_test=True,
|
||||
).import_file_button()
|
||||
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
||||
self.assertEqual(len(statement), 1)
|
||||
@@ -134,9 +123,7 @@ class TestAccountBankStatementImportPayPal(common.TransactionCase):
|
||||
"currency_id": self.currency_usd.id,
|
||||
}
|
||||
)
|
||||
wizard = self.AccountStatementImport.with_context(
|
||||
{"journal_id": journal.id}
|
||||
).create(
|
||||
wizard = self.AccountStatementImport.with_context(journal_id=journal.id).create(
|
||||
{
|
||||
"statement_filename": "fixtures/activity_en.csv",
|
||||
"statement_file": self._data_file("fixtures/activity_en.csv"),
|
||||
@@ -144,10 +131,8 @@ class TestAccountBankStatementImportPayPal(common.TransactionCase):
|
||||
}
|
||||
)
|
||||
wizard.with_context(
|
||||
{
|
||||
"journal_id": journal.id,
|
||||
"account_statement_import_paypal_test": True,
|
||||
}
|
||||
journal_id=journal.id,
|
||||
account_statement_import_paypal_test=True,
|
||||
).import_file_button()
|
||||
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
||||
self.assertEqual(len(statement), 1)
|
||||
@@ -162,9 +147,7 @@ class TestAccountBankStatementImportPayPal(common.TransactionCase):
|
||||
"currency_id": self.currency_usd.id,
|
||||
}
|
||||
)
|
||||
wizard = self.AccountStatementImport.with_context(
|
||||
{"journal_id": journal.id}
|
||||
).create(
|
||||
wizard = self.AccountStatementImport.with_context(journal_id=journal.id).create(
|
||||
{
|
||||
"statement_filename": "fixtures/empty_activity.csv",
|
||||
"statement_file": self._data_file("fixtures/empty_activity.csv"),
|
||||
@@ -173,10 +156,8 @@ class TestAccountBankStatementImportPayPal(common.TransactionCase):
|
||||
)
|
||||
with self.assertRaises(UserError):
|
||||
wizard.with_context(
|
||||
{
|
||||
"journal_id": journal.id,
|
||||
"account_statement_import_paypal_test": True,
|
||||
}
|
||||
journal_id=journal.id,
|
||||
account_statement_import_paypal_test=True,
|
||||
).import_file_button()
|
||||
statement = self.AccountBankStatement.search([("journal_id", "=", journal.id)])
|
||||
self.assertEqual(len(statement), 0)
|
||||
|
||||
Reference in New Issue
Block a user