This commit is contained in:
Pedro M. Baeza
2014-08-04 15:29:05 +02:00
parent 2c1773e7be
commit 44a59ce588
60 changed files with 615 additions and 458 deletions

View File

@@ -37,11 +37,13 @@ class CreditPartnerStatementImporter(orm.TransientModel):
context = {}
res = {}
if (context.get('active_model', False) == 'account.statement.profile' and
context.get('active_ids', False)):
context.get('active_ids', False)):
ids = context['active_ids']
assert len(ids) == 1, 'You cannot use this on more than one profile !'
assert len(
ids) == 1, 'You cannot use this on more than one profile !'
res['profile_id'] = ids[0]
other_vals = self.onchange_profile_id(cr, uid, [], res['profile_id'], context=context)
other_vals = self.onchange_profile_id(
cr, uid, [], res['profile_id'], context=context)
res.update(other_vals.get('value', {}))
return res
@@ -72,21 +74,21 @@ class CreditPartnerStatementImporter(orm.TransientModel):
res = {}
if profile_id:
c = self.pool.get("account.statement.profile").browse(
cr, uid, profile_id, context=context)
cr, uid, profile_id, context=context)
res = {'value':
{'partner_id': c.partner_id and c.partner_id.id or False,
'journal_id': c.journal_id and c.journal_id.id or False,
'receivable_account_id': c.receivable_account_id and c.receivable_account_id.id or False,
'force_partner_on_bank': c.force_partner_on_bank,
'balance_check': c.balance_check,
}
}
{'partner_id': c.partner_id and c.partner_id.id or False,
'journal_id': c.journal_id and c.journal_id.id or False,
'receivable_account_id': c.receivable_account_id and c.receivable_account_id.id or False,
'force_partner_on_bank': c.force_partner_on_bank,
'balance_check': c.balance_check,
}
}
return res
def _check_extension(self, filename):
(__, ftype) = os.path.splitext(filename)
if not ftype:
#We do not use osv exception we do not want to have it logged
# We do not use osv exception we do not want to have it logged
raise Exception(_('Please use a file with an extention'))
return ftype
@@ -99,18 +101,19 @@ class CreditPartnerStatementImporter(orm.TransientModel):
ftype = self._check_extension(importer.file_name)
context['file_name'] = importer.file_name
sid = self.pool.get(
'account.statement.profile').multi_statement_import(
cr,
uid,
False,
importer.profile_id.id,
importer.input_statement,
ftype.replace('.', ''),
context=context
)
'account.statement.profile').multi_statement_import(
cr,
uid,
False,
importer.profile_id.id,
importer.input_statement,
ftype.replace('.', ''),
context=context
)
model_obj = self.pool.get('ir.model.data')
action_obj = self.pool.get('ir.actions.act_window')
action_id = model_obj.get_object_reference(cr, uid, 'account', 'action_bank_statement_tree')[1]
action_id = model_obj.get_object_reference(
cr, uid, 'account', 'action_bank_statement_tree')[1]
res = action_obj.read(cr, uid, action_id)
res['domain'] = res['domain'][:-1] + ",('id', 'in', %s)]" % sid
return res