[FIX]Account Bank Statment Import CCoop
* Check CCoop CSV file, to allow import chain ; * Convert ISO to UTF8.
This commit is contained in:
parent
a6b93ab061
commit
d9c9fa52ff
@ -22,7 +22,7 @@
|
||||
* For CSV published by Crédit Coopératif on their website customer space ;
|
||||
* Adds option on bank import statement wizard ;
|
||||
* Checks and processes file.""",
|
||||
'version': '10.0.0.1.0',
|
||||
'version': '10.0.0.1.1',
|
||||
'category': 'Banking addons',
|
||||
'author': 'Fabien Bourgeois',
|
||||
'license': 'AGPL-3',
|
||||
|
@ -6,8 +6,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 10.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-09-12 13:28+0000\n"
|
||||
"PO-Revision-Date: 2018-09-12 13:28+0000\n"
|
||||
"POT-Creation-Date: 2018-09-12 15:22+0000\n"
|
||||
"PO-Revision-Date: 2018-09-12 15:22+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@ -25,9 +25,3 @@ msgstr ""
|
||||
msgid "Import Bank Statement"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_bank_statement_import_ccoop
|
||||
#: code:addons/account_bank_statement_import_ccoop/wizard/account_bank_statement_import.py:41
|
||||
#, python-format
|
||||
msgid "Invalid filetype, expected CSV"
|
||||
msgstr ""
|
||||
|
||||
|
@ -6,8 +6,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 10.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-09-12 13:28+0000\n"
|
||||
"PO-Revision-Date: 2018-09-12 15:28+0200\n"
|
||||
"POT-Creation-Date: 2018-09-12 15:23+0000\n"
|
||||
"PO-Revision-Date: 2018-09-12 15:23+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@ -25,9 +25,3 @@ msgstr "Crédit Coop (.CSV)"
|
||||
msgid "Import Bank Statement"
|
||||
msgstr "Import d'un relevé bancaire"
|
||||
|
||||
#. module: account_bank_statement_import_ccoop
|
||||
#: code:addons/account_bank_statement_import_ccoop/wizard/account_bank_statement_import.py:41
|
||||
#, python-format
|
||||
msgid "Invalid filetype, expected CSV"
|
||||
msgstr "Type de fichier invalide, format CSV attendu"
|
||||
|
||||
|
@ -32,20 +32,23 @@ class AccountBankStatementImport(models.TransientModel):
|
||||
""" Bank statement import : CSV from Credit Coop """
|
||||
_inherit = 'account.bank.statement.import'
|
||||
|
||||
@api.multi
|
||||
def import_file(self):
|
||||
""" Check filetype before loading data """
|
||||
self.ensure_one()
|
||||
file_type = guess_type(self.filename)[0]
|
||||
if file_type != 'text/csv':
|
||||
raise ValidationError(_('Invalid filetype, expected CSV'))
|
||||
return super(AccountBankStatementImport, self).import_file()
|
||||
|
||||
@api.model
|
||||
def _load_ccop_csv(self, data_file):
|
||||
""" Parses and load CSV from CCoop """
|
||||
csv_data = csv.reader(data_file.split('\n'), delimiter=';')
|
||||
return [line for line in csv_data]
|
||||
return [[cell.decode('iso-8859-15').encode('utf8') for cell in line]
|
||||
for line in csv_data]
|
||||
|
||||
@api.model
|
||||
def _check_load_ccoop(self, data_file):
|
||||
""" Check filetype and CCoop before loading data """
|
||||
file_type = guess_type(self.filename)[0]
|
||||
if file_type != 'text/csv':
|
||||
return False
|
||||
data = self._load_ccop_csv(data_file)
|
||||
if not data[0][0].startswith('Code de la banque : '):
|
||||
return False
|
||||
return data
|
||||
|
||||
@api.model
|
||||
def _get_coop_transaction(self, account_number, line):
|
||||
@ -82,6 +85,8 @@ class AccountBankStatementImport(models.TransientModel):
|
||||
|
||||
def _parse_file(self, data_file):
|
||||
""" Implements parse_file from parent, returning the required triplet """
|
||||
data = self._load_ccop_csv(data_file)
|
||||
data = self._check_load_ccoop(data_file)
|
||||
if not data:
|
||||
return super(AccountBankStatementImport, self)._parse_file(data_file)
|
||||
currency, account_number, bank_statement_data = self._get_ccop_processed(data)
|
||||
return currency, account_number, [bank_statement_data]
|
||||
|
Loading…
x
Reference in New Issue
Block a user