[FIX]Page title, bank statement line name(ref),temporary account, journal_id false
bzr revid: dle@openerp.com-20121220145227-mgib0p9j0d8ui7pm
This commit is contained in:
parent
db00d1f61a
commit
53e0bbf2e6
|
@ -38,8 +38,8 @@ class account_bank_statement_line(osv.osv):
|
|||
|
||||
def create(self, cr, uid, data, context=None):
|
||||
"""
|
||||
This function creates a Bank Account Number if, for a bank statement line,
|
||||
the partner_id field and the coda_account_number field are set,
|
||||
This function creates a Bank Account Number if, for a bank statement line,
|
||||
the partner_id field and the coda_account_number field are set,
|
||||
and the account number does not exist in the database
|
||||
"""
|
||||
if 'partner_id' in data and data['partner_id'] and 'coda_account_number' in data and data['coda_account_number']:
|
||||
|
@ -53,8 +53,6 @@ class account_bank_statement_line(osv.osv):
|
|||
pass
|
||||
return super(account_bank_statement_line, self).create(cr, uid, data, context=context)
|
||||
|
||||
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
super(account_bank_statement_line, self).write(cr, uid, ids, vals, context)
|
||||
"""
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<form string="Import CODA File" version="7.0">
|
||||
<group col="2">
|
||||
<field name="coda_data" filename="coda_fname"/>
|
||||
<field name="temporary_account_id" />
|
||||
</group>
|
||||
<footer>
|
||||
<button name="coda_parsing" string="_Import" type="object" class="oe_highlight"/>
|
||||
|
|
|
@ -36,9 +36,20 @@ class account_coda_import(osv.osv_memory):
|
|||
'coda_data': fields.binary('CODA File', required=True),
|
||||
'coda_fname': fields.char('CODA Filename', size=128, required=True),
|
||||
'note': fields.text('Log'),
|
||||
'temporary_account_id': fields.many2one('account.account', 'Temporary Account', domain="[('type','!=','view')]", help="It acts as a temporary account for general amount", required=True),
|
||||
}
|
||||
|
||||
def _get_default_tmp_account(self, cr, uid, context):
|
||||
tmp_accounts = self.pool.get('account.account').search(cr, uid, [('code', '=', '490000')])
|
||||
if tmp_accounts and len(tmp_accounts) > 0:
|
||||
tmp_account_id = tmp_accounts[0]
|
||||
else:
|
||||
tmp_account_id = False
|
||||
return tmp_account_id
|
||||
|
||||
_defaults = {
|
||||
'coda_fname': lambda *a: '',
|
||||
'temporary_account_id': _get_default_tmp_account,
|
||||
}
|
||||
|
||||
def coda_parsing(self, cr, uid, ids, context=None, batch=False, codafile=None, codafilename=None):
|
||||
|
@ -52,6 +63,7 @@ class account_coda_import(osv.osv_memory):
|
|||
try:
|
||||
codafile = data.coda_data
|
||||
codafilename = data.coda_fname
|
||||
temporaryaccount = data.temporary_account_id.id
|
||||
except:
|
||||
raise osv.except_osv(_('Error'), _('Wizard in incorrect state. Please hit the Cancel button'))
|
||||
return {}
|
||||
|
@ -107,11 +119,11 @@ class account_coda_import(osv.osv_memory):
|
|||
if bank_ids and len(bank_ids) > 0:
|
||||
bank_accs = self.pool.get('res.partner.bank').browse(cr, uid, bank_ids)
|
||||
for bank_acc in bank_accs:
|
||||
if not (bank_acc.journal_id and (bank_acc.journal_id.currency and bank_acc.journal_id.currency.name != statement['currency']) and (not bank_acc.journal_id.currency and bank_acc.journal_id.company_id.currency_id.name != statement['currency'])):
|
||||
if bank_acc.journal_id.id and ((bank_acc.journal_id.currency.id and bank_acc.journal_id.currency.name == statement['currency']) or (not bank_acc.journal_id.currency.id and bank_acc.journal_id.company_id.currency_id.name == statement['currency'])):
|
||||
statement['journal_id'] = bank_acc.journal_id
|
||||
statement['bank_account'] = bank_acc
|
||||
break
|
||||
if statement['bank_account'] == False:
|
||||
if not statement['bank_account']:
|
||||
raise osv.except_osv(_('Error') + ' R1004', _("No matching Bank Account (with Account Journal) found.\n\nPlease set-up a Bank Account with as Account Number '%s' and as Currency '%s' and an Account Journal.") % (statement['acc_number'], statement['currency']))
|
||||
statement['description'] = rmspaces(line[90:125])
|
||||
statement['balance_start'] = float(rmspaces(line[43:58])) / 1000
|
||||
|
@ -252,7 +264,7 @@ class account_coda_import(osv.osv_memory):
|
|||
if balance_start_check != statement['balance_start']:
|
||||
statement['coda_note'] = _("The CODA Statement %s Starting Balance (%.2f) does not correspond with the previous Closing Balance (%.2f) in journal %s!") % (statement['description'] + ' #' + statement['paperSeqNumber'], statement['balance_start'], balance_start_check, statement['journal_id'].name)
|
||||
data = {
|
||||
'name': '[' + statement['date'] + ']' + statement['description'],
|
||||
'name': statement['paperSeqNumber'],
|
||||
'date': statement['date'],
|
||||
'journal_id': statement['journal_id'].id,
|
||||
'period_id': statement['period_id'],
|
||||
|
@ -353,10 +365,7 @@ class account_coda_import(osv.osv_memory):
|
|||
if partner.supplier:
|
||||
line['transaction_type'] = 'supplier'
|
||||
if not partner and not invoice:
|
||||
if line['debit'] == '1':
|
||||
line['account'] = statement['journal_id'].default_debit_account_id.id
|
||||
else:
|
||||
line['account'] = statement['journal_id'].default_credit_account_id.id
|
||||
line['account'] = temporaryaccount
|
||||
if 'communication' in line and line['communication'] != '':
|
||||
note.append(_('Communication') + ': ' + line['communication'])
|
||||
if 'voucher_id' not in line:
|
||||
|
@ -379,6 +388,7 @@ class account_coda_import(osv.osv_memory):
|
|||
if statement['coda_note'] != '':
|
||||
self.pool.get('account.bank.statement').write(cr, uid, [statement['id']], {'coda_note': statement['coda_note']}, context=context)
|
||||
return {
|
||||
'name': 'Bank Statements',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'account.bank.statement',
|
||||
|
|
Loading…
Reference in New Issue