136
136
vals.update(parser.get_st_vals())
139
def statement_import(self, cr, uid, ids, profile_id, file_stream, ftype="csv", context=None):
139
def multi_statement_import(self, cr, uid, ids, profile_id, file_stream,
140
ftype="csv", context=None):
142
Create multiple bank statements from values given by the parser for the
145
:param int/long profile_id: ID of the profile used to import the file
146
:param filebuffer file_stream: binary of the providen file
147
:param char: ftype represent the file exstension (csv by default)
148
:return: list: list of ids of the created account.bank.statemênt
150
prof_obj = self.pool['account.statement.profile']
152
raise osv.except_osv(_("No Profile!"),
153
_("You must provide a valid profile to import a bank statement!"))
154
prof = prof_obj.browse(cr, uid, profile_id, context=context)
156
parser = new_bank_statement_parser(prof.import_type, ftype=ftype)
158
for result_row_list in parser.parse(file_stream):
159
statement_id = self._statement_import(cr, uid, ids, prof, parser,
160
file_stream, ftype=ftype, context=context)
161
res.append(statement_id)
164
def _statement_import(self, cr, uid, ids, prof, parser, file_stream, ftype="csv", context=None):
141
166
Create a bank statement with the given profile and parser. It will fullfill the bank statement
142
167
with the values of the file providen, but will not complete data (like finding the partner, or
143
168
the right account). This will be done in a second step with the completion rules.
145
:param int/long profile_id: ID of the profile used to import the file
170
:param prof : The profile used to import the file
171
:param parser: the parser
146
172
:param filebuffer file_stream: binary of the providen file
147
173
:param char: ftype represent the file exstension (csv by default)
148
174
:return: ID of the created account.bank.statemênt
150
176
statement_obj = self.pool.get('account.bank.statement')
151
177
statement_line_obj = self.pool.get('account.bank.statement.line')
152
178
attachment_obj = self.pool.get('ir.attachment')
153
prof_obj = self.pool.get("account.statement.profile")
155
raise osv.except_osv(_("No Profile!"),
156
_("You must provide a valid profile to import a bank statement!"))
157
prof = prof_obj.browse(cr, uid, profile_id, context=context)
159
parser = new_bank_statement_parser(prof.import_type, ftype=ftype)
160
result_row_list = parser.parse(file_stream)
180
result_row_list = parser.result_row_list
161
181
# Check all key are present in account.bank.statement.line!!
162
182
if not result_row_list:
163
183
raise osv.except_osv(_("Nothing to import"),