mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
[FIX] conversion_dict is now created in the generic parser
This commit is contained in:
@@ -42,7 +42,7 @@ class FileParser(BankStatementImportParser):
|
||||
"""
|
||||
:param char: parse_name: The name of the parser
|
||||
:param char: ftype: extension of the file (could be csv, xls or xlsx)
|
||||
:param dict: extra_fields: extra fields to add to the conversion dict. In the format
|
||||
:param dict: extra_fields: extra fields to put into the conversion dict. In the format
|
||||
{fieldname: fieldtype}
|
||||
:param list: header : specify header fields if the csv file has no header
|
||||
"""
|
||||
@@ -53,14 +53,7 @@ class FileParser(BankStatementImportParser):
|
||||
else:
|
||||
raise except_osv(_('User Error'),
|
||||
_('Invalid file type %s. Please use csv, xls or xlsx') % ftype)
|
||||
self.conversion_dict = {
|
||||
'ref': unicode,
|
||||
'label': unicode,
|
||||
'date': datetime.datetime,
|
||||
'amount': float_or_zero,
|
||||
}
|
||||
if extra_fields:
|
||||
self.conversion_dict.update(extra_fields)
|
||||
self.conversion_dict = extra_fields
|
||||
self.keys_to_validate = self.conversion_dict.keys()
|
||||
self.fieldnames = header
|
||||
self._datemode = 0 # used only for xls documents,
|
||||
|
||||
@@ -24,6 +24,7 @@ import csv
|
||||
import tempfile
|
||||
import datetime
|
||||
from file_parser import FileParser
|
||||
+from openerp.addons.account_statement_base_import.parser.file_parser import float_or_zero
|
||||
try:
|
||||
import xlrd
|
||||
except:
|
||||
@@ -38,7 +39,13 @@ class GenericFileParser(FileParser):
|
||||
"""
|
||||
|
||||
def __init__(self, parse_name, ftype='csv', **kwargs):
|
||||
super(GenericFileParser, self).__init__(parse_name, ftype=ftype, **kwargs)
|
||||
conversion_dict = {
|
||||
'ref': unicode,
|
||||
'label': unicode,
|
||||
'date': datetime.datetime,
|
||||
'amount': float_or_zero,
|
||||
}
|
||||
super(GenericFileParser, self).__init__(parse_name, ftype=ftype, extra_fields=conversion_dict, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def parser_for(cls, parser_name):
|
||||
|
||||
Reference in New Issue
Block a user