From 390363d7e1d42a740fe057586b885d84d656a72e Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 24 May 2017 12:00:40 +0200 Subject: [PATCH] [FIX] disable auto-delete of already imported lines of HSBC CB because experience shows we can have 2 payments same day, same hour, same merchant and same amount (in particular for internet payments that often have hour=00:00) --- .../wizard/account_bank_statement_import.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/account_bank_statement_import_fr_hsbc_card/wizard/account_bank_statement_import.py b/account_bank_statement_import_fr_hsbc_card/wizard/account_bank_statement_import.py index 8026a55..ff4fe25 100644 --- a/account_bank_statement_import_fr_hsbc_card/wizard/account_bank_statement_import.py +++ b/account_bank_statement_import_fr_hsbc_card/wizard/account_bank_statement_import.py @@ -72,7 +72,7 @@ class AccountBankStatementImport(models.TransientModel): end_balance += amount date_dt = datetime.strptime(line['date'], '%d/%m/%Y') date_str = fields.Date.to_string(date_dt) - if line[u'acc_currency'] != currency_code: + if line['acc_currency'] != currency_code: raise UserError(_( "On line %d of the HSBC CSV file, the column " "'Dev Cpt Affaires' contains '%s' instead of 'EUR'") @@ -81,8 +81,14 @@ class AccountBankStatementImport(models.TransientModel): 'date': date_str, 'name': name, 'ref': False, - 'unique_import_id': '%s-%s-%.2f-%s' % ( - date_str, line['hour'], amount, name), + # unfortunately, I'm obliged to include i in + # the unique_import_id, which will disable the auto-delete + # of already imported lines. But experice has proven that + # Internet payment often have hour=00:00, and it's possible + # to have 2 internet payments for the same supplier the same + # day with the same amount (e.g. purchase a return ticket) + 'unique_import_id': '%s-%s-%.2f-%s-%d' % ( + date_str, line['hour'], amount, name, i), 'amount': amount, 'partner_id': False, }