[REF] add a prepare method for custom for creating the bank statement

This commit is contained in:
Sebastien Beau
2013-12-04 18:39:04 +01:00
parent 9205414ee1
commit 1648c431f7

View File

@@ -126,6 +126,15 @@ class AccountStatementProfil(Model):
values['type'] = 'general' values['type'] = 'general'
return values return values
def _prepare_statement_vals(self, cr, uid, prof, parser, context=None):
return {
'profile_id': prof.id,
'name': parser.get_statement_name(),
'balance_start': parser.get_start_balance(),
'balance_end_real': parser.get_end_balance(),
}
def statement_import(self, cr, uid, ids, profile_id, file_stream, ftype="csv", context=None): def statement_import(self, cr, uid, ids, profile_id, file_stream, ftype="csv", context=None):
""" """
Create a bank statement with the given profile and parser. It will fullfill the bank statement Create a bank statement with the given profile and parser. It will fullfill the bank statement
@@ -158,13 +167,8 @@ class AccountStatementProfil(Model):
raise osv.except_osv(_("Missing column!"), raise osv.except_osv(_("Missing column!"),
_("Column %s you try to import is not " _("Column %s you try to import is not "
"present in the bank statement line!") % col) "present in the bank statement line!") % col)
st_vals = {
'profile_id': prof.id, st_vals = self._prepare_statement_vals(cr, uid, prof, parser, context=context)
'name': parser.get_statement_name(),
'balance_start': parser.get_start_balance(),
'balance_end_real': parser.get_end_balance(),
}
statement_id = statement_obj.create(cr, uid, st_vals, context=context) statement_id = statement_obj.create(cr, uid, st_vals, context=context)
if prof.receivable_account_id: if prof.receivable_account_id:
account_receivable = account_payable = prof.receivable_account_id.id account_receivable = account_payable = prof.receivable_account_id.id