[MERGE](Sort of :D)From Luc De Meyer Zip from apps.openerp.com

bzr revid: dle@openerp.com-20121130172033-dinqyw8arg79eh31
This commit is contained in:
dle@openerp.com 2012-11-30 18:20:33 +01:00
parent 759416678b
commit 6f3f1d4217
5 changed files with 1577 additions and 470 deletions

View File

@ -2,9 +2,9 @@
##############################################################################
#
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2011 Noviat nv/sa (www.noviat.be). All rights reserved.
#
#
# Copyright (c) 2012 Noviat nv/sa (www.noviat.be). All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
@ -23,20 +23,29 @@
from osv import osv, fields
import decimal_precision as dp
from tools.translate import _
import logging
_logger = logging.getLogger(__name__)
class coda_bank_account(osv.osv):
_name= 'coda.bank.account'
_description= 'CODA Bank Account Configuration'
def _check_account_pain(self, cr, uid, context=None):
res = self.pool.get('ir.module.module').search(cr, uid, [('name', '=', 'account_pain'), ('state','=','installed')])
return res and True or False
def _check_currency(self, cr, uid, ids, context=None):
obj_cba = self.browse(cr, uid, ids[0], context=context)
if (obj_cba.state == 'normal') and obj_cba.journal and (obj_cba.currency != obj_cba.journal.currency and (not obj_cba.journal.currency and obj_cba.currency != obj_cba.company_id.currency_id)):
return False
if (obj_cba.state == 'normal') and obj_cba.journal:
if obj_cba.journal.currency and (obj_cba.currency != obj_cba.journal.currency):
return False
if not obj_cba.journal.currency and (obj_cba.currency != obj_cba.company_id.currency_id):
return False
return True
_columns = {
'name': fields.char('Name', size=64, required=True),
'bank_id': fields.many2one('res.partner.bank', 'Bank Account', required=True,
'bank_id': fields.many2one('res.partner.bank', 'Bank Account', required=True,
help='Bank Account Number.\nThe CODA import function will find its CODA processing parameters on this number.'),
'description1': fields.char('Primary Account Description', size=35,
help='The Primary or Secondary Account Description should match the corresponding Account Description in the CODA file.'),
@ -44,34 +53,47 @@ class coda_bank_account(osv.osv):
help='The Primary or Secondary Account Description should match the corresponding Account Description in the CODA file.'),
'state': fields.selection([
('normal', 'Normal'),
('info', 'Info')],
('info', 'Info')],
'Type', required=True, select=1,
help='No Bank Statements will be generated for CODA Bank Statements from Bank Accounts of type \'Info\'.'),
'journal': fields.many2one('account.journal', 'Journal',
domain=[('type', '=', 'bank')],
'journal': fields.many2one('account.journal', 'Journal',
domain=[('type', '=', 'bank')],
states={'normal':[('required',True)],'info':[('required',False)]},
help='Bank Journal for the Bank Statement'),
'currency': fields.many2one('res.currency', 'Currency', required=True,
help='The currency of the CODA Bank Statement'),
help='The currency of the CODA Bank Statement'),
'coda_st_naming': fields.char('Bank Statement Naming Policy', size=64,
help="Define the rules to create the name of the Bank Statements generated by the CODA processing." \
"\nE.g. %(code)s%(y)s/%(paper)s"
"\nE.g. %(code)s%(y)s/%(paper)s" \
"\n\nVariables:" \
"\nBank Journal Code: %(code)s" \
"\nCurrent Year with Century: %(year)s" \
"\nCurrent Year without Century: %(y)s" \
"\nYear (of CODA 'New Balance Date') with Century: %(year)s" \
"\nYear (of CODA 'New Balance Date') without Century: %(y)s" \
"\nCODA sequence number: %(coda)s" \
"\nPaper Statement sequence number: %(paper)s"),
'def_payable': fields.many2one('account.account', 'Default Payable Account', domain=[('type', '=', 'payable')], required=True,
help= 'Set here the payable account that will be used, by default, if the partner is not found.'),
'def_receivable': fields.many2one('account.account', 'Default Receivable Account', domain=[('type', '=', 'receivable')], required=True,
help= 'Set here the receivable account that will be used, by default, if the partner is not found.',),
"\nPaper Statement sequence number (as specified on 'Old Balance' record): %(paper_ob)s" \
"\nPaper Statement sequence number (as specified on 'New Balance' record): %(paper)s"),
'awaiting_account': fields.many2one('account.account', 'Default Account for Unrecognized Movement', domain=[('type', '!=', 'view')], required=True,
help= 'Set here the default account that will be used if the partner cannot be unambiguously identified.'),
'transfer_account': fields.many2one('account.account', 'Default Internal Transfer Account', domain=[('code', 'like', '58%'), ('type', '!=', 'view')], required=True,
help= 'Set here the default account that will be used for internal transfer between own bank accounts (e.g. transfer between current and deposit bank accounts).'),
'find_bbacom': fields.boolean('Lookup Invoice', required=True, help='Partner lookup via the \'BBA\' Structured Communication field of the Invoice.'),
'find_partner': fields.boolean('Lookup Partner', required=True, help='Partner lookup via Bank Account Number.'),
'account_mapping_ids': fields.one2many('coda.account.mapping.rule', 'coda_bank_account_id', 'Account Mapping Rules'),
'find_payment': fields.boolean('Lookup Payment Reference',
help='Invoice lookup and reconciliation via the SEPA EndToEndReference.' \
'\nInstall the \'account_pain\' module if you want to take advantage of this feature.'),
'find_bbacom': fields.boolean('Lookup Structured Communication of type \'BBA\'',
help='Partner lookup and reconciliation via the \'BBA\' Structured Communication.' \
'\nA partial reconciliation will be created when there is no exact match between the Invoice and Bank Transaction amounts.'),
'find_inv_number': fields.boolean('Lookup Invoice Number',
help='Partner lookup and reconciliation via the Invoice Number when a communication in free format is used.' \
'\nA reconciliation will only be created in case of exact match between the Invoice and Bank Transaction amounts.'),
'find_partner': fields.boolean('Lookup Partner',
help='Partner lookup via Bank Account Number in order to facilitate the reconciliation.'),
'update_partner': fields.boolean('Update Partner Bank Accounts',
help='Update Partner record when the Counterparty\'s Bank Account has not been registered yet.'),
'balance_start_enforce': fields.boolean('Prevent invalid Opening Balances',
help="Do not process Statements with an Opening Balance that doesn't match the previous Closing Balance."),
'discard_dup': fields.boolean('Discard Duplicates',
help="Duplicate Bank Statements will be discarded. Select the corresponding 'CODA Bank Statement' in order to view the contents of such duplicates."),
'active': fields.boolean('Active', help='If the active field is set to False, it will allow you to hide the Bank Account without removing it.'),
'company_id': fields.many2one('res.company', 'Company', required=True),
}
@ -79,9 +101,13 @@ class coda_bank_account(osv.osv):
'currency': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.currency_id.id,
'state': 'normal',
'coda_st_naming': '%(code)s/%(y)s/%(coda)s',
'active': True,
'active': True,
'find_payment': _check_account_pain,
'find_bbacom': True,
'find_partner': True,
'find_inv_number': True,
'find_partner': True,
'update_partner': True,
'balance_start_enforce': True,
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
}
_sql_constraints = [
@ -107,19 +133,20 @@ class coda_bank_account(osv.osv):
if not default:
default = {}
default = default.copy()
default.update(
journal_id=None,
description1=cba['description1'] or '',
description2=cba['description2'] or '',
name=_("%s (copy)") % (cba['name'] or ''),
state=cba['state'])
return super(coda_bank_account, self).copy(cr, uid, id, default, context)
default.update({'journal_id': None})
default['description1'] = cba['description1'] or ''
default['description2'] = cba['description2'] or ''
default['name'] = (cba['name'] or '') + ' (copy)'
default['state'] = cba['state']
return super(coda_bank_account, self).copy(cr, uid, id, default, context)
def onchange_state(self, cr, uid, ids, state):
return state =='info' and {'value': {'journal': None}} or {}
coda_bank_account()
class account_coda(osv.osv):
_name = 'account.coda'
_description = 'Object to store CODA Data Files'
@ -138,10 +165,10 @@ class account_coda(osv.osv):
'date': fields.date.context_today,
'user_id': lambda self,cr,uid,context: uid,
'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'account.coda', context=c),
}
}
_sql_constraints = [
('coda_uniq', 'unique (name, coda_creation_date)', 'This CODA has already been imported !')
]
]
def unlink(self, cr, uid, ids, context=None):
if context is None:
@ -150,79 +177,73 @@ class account_coda(osv.osv):
coda_st_obj = self.pool.get('coda.bank.statement')
bank_st_obj = self.pool.get('account.bank.statement')
for coda in self.browse(cr, uid, ids, context=context):
for coda_statement in coda.statement_ids:
for coda_statement in coda.statement_ids:
if not context.get('coda_statement_unlink', False):
if coda_st_obj.exists(cr, uid, coda_statement.id, context=context):
coda_st_obj.unlink(cr, uid, [coda_statement.id], context=context)
coda_st_obj.unlink(cr, uid, [coda_statement.id], context=context)
if not context.get('bank_statement_unlink', False):
if coda_st_obj.exists(cr, uid, coda_statement.id, context=context) and (coda_statement.type == 'normal') and bank_st_obj.exists(cr, uid, coda_statement.statement_id.id, context=context):
bank_st_obj.unlink(cr, uid, [coda_statement.statement_id.id], context=context)
bank_st_obj.unlink(cr, uid, [coda_statement.statement_id.id], context=context)
context.update({'coda_unlink': False})
return super(account_coda, self).unlink(cr, uid, ids, context=context)
account_coda()
class account_coda_trans_type(osv.osv):
class account_coda_trans_type(osv.osv):
_name = 'account.coda.trans.type'
_description = 'CODA transaction type'
_rec_name = 'type'
_rec_name = 'type'
_columns = {
'type': fields.char('Transaction Type', size=1, required=True),
'parent_id': fields.many2one('account.coda.trans.type', 'Parent'),
'description': fields.text('Description', translate=True),
}
account_coda_trans_type()
class account_coda_trans_code(osv.osv):
class account_coda_trans_code(osv.osv):
_name = 'account.coda.trans.code'
_description = 'CODA transaction code'
_rec_name = 'code'
_rec_name = 'code'
_columns = {
'code': fields.char('Code', size=2, required=True, select=1),
'type': fields.selection([
('code', 'Transaction Code'),
('family', 'Transaction Family')],
'Type', required=True, select=1),
('family', 'Transaction Family')],
'Type', required=True, select=1),
'parent_id': fields.many2one('account.coda.trans.code', 'Family', select=1),
'description': fields.char('Description', size=128, translate=True, select=2),
'comment': fields.text('Comment', translate=True),
}
account_coda_trans_code()
class account_coda_trans_category(osv.osv):
class account_coda_trans_category(osv.osv):
_name = 'account.coda.trans.category'
_description = 'CODA transaction category'
_rec_name = 'category'
_rec_name = 'category'
_columns = {
'category': fields.char('Transaction Category', size=3, required=True),
'description': fields.char('Description', size=256, translate=True),
}
account_coda_trans_category()
class account_coda_comm_type(osv.osv):
class account_coda_comm_type(osv.osv):
_name = 'account.coda.comm.type'
_description = 'CODA structured communication type'
_rec_name = 'code'
_rec_name = 'code'
_columns = {
'code': fields.char('Structured Communication Type', size=3, required=True, select=1),
'description': fields.char('Description', size=128, translate=True),
}
_sql_constraints = [
('code_uniq', 'unique (code)','The Structured Communication Code must be unique !')
]
]
account_coda_comm_type()
class coda_bank_statement(osv.osv):
_name = 'coda.bank.statement'
_description = 'CODA Bank Statement'
def _default_journal_id(self, cr, uid, context=None):
if context is None:
context = {}
_name = 'coda.bank.statement'
_description = 'CODA Bank Statement'
def _default_journal_id(self, cr, uid, context={}):
if context.get('journal_id', False):
return context['journal_id']
return False
@ -238,7 +259,7 @@ class coda_bank_statement(osv.osv):
res[r] = round(res[r], 2)
return res
def _get_period(self, cr, uid, context=None):
def _get_period(self, cr, uid, context={}):
periods = self.pool.get('account.period').find(cr, uid)
if periods:
return periods[0]
@ -249,19 +270,22 @@ class coda_bank_statement(osv.osv):
_columns = {
'name': fields.char('Name', size=64, required=True, readonly=True),
'date': fields.date('Date', required=True, readonly=True),
'coda_creation_date': fields.date('CODA Creation Date', readonly=True),
'old_balance_date': fields.date('Old Balance Date', readonly=True),
'new_balance_date': fields.date('New Balance Date', readonly=True),
'coda_id': fields.many2one('account.coda', 'CODA Data File', ondelete='cascade'),
'type': fields.selection([
('normal', 'Normal'),
('info', 'Info')],
('info', 'Info')],
'Type', required=True, readonly=True,
help='No Bank Statements are associated with CODA Bank Statements of type \'Info\'.'),
'statement_id': fields.many2one('account.bank.statement', 'Associated Bank Statement'),
'statement_id': fields.many2one('account.bank.statement', 'Associated Bank Statement'),
'journal_id': fields.many2one('account.journal', 'Journal', readonly=True, domain=[('type', '=', 'bank')]),
'coda_bank_account_id': fields.many2one('coda.bank.account', 'Bank Account', readonly=True),
'coda_bank_account_id': fields.many2one('coda.bank.account', 'Bank Account', readonly=True),
'period_id': fields.many2one('account.period', 'Period', required=True, readonly=True),
'balance_start': fields.float('Starting Balance', digits_compute=dp.get_precision('Account'), readonly=True),
'balance_end_real': fields.float('Ending Balance', digits_compute=dp.get_precision('Account'), readonly=True),
'balance_end': fields.function(_end_balance, method=True, store=True, string='Balance'),
'balance_end': fields.function(_end_balance, method=True, store=True, string='Balance'),
'line_ids': fields.one2many('coda.bank.statement.line',
'statement_id', 'CODA Bank Statement lines', readonly=True),
'currency': fields.many2one('res.currency', 'Currency', required=True, readonly=True,
@ -269,14 +293,14 @@ class coda_bank_statement(osv.osv):
'company_id': fields.related('journal_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
}
_defaults = {
'type': 'normal',
'type': 'normal',
'currency': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.currency_id.id,
'journal_id': _default_journal_id,
'period_id': _get_period,
}
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
if context is None:
if context is None:
context = {}
res = super(coda_bank_statement, self).search(cr, uid, args=args, offset=offset, limit=limit, order=order,
context=context, count=count)
@ -290,20 +314,20 @@ class coda_bank_statement(osv.osv):
context.update({'coda_statement_unlink': True})
coda_obj = self.pool.get('account.coda')
bank_st_obj = self.pool.get('account.bank.statement')
# find all CODA bank statements that are associated with the selected CODA bank statements via a common CODA file
new_ids = []
new_ids = []
for coda_statement in self.browse(cr, uid, ids, context=context):
if coda_obj.exists(cr, uid, coda_statement.coda_id.id, context=context):
new_ids += [x.id for x in coda_obj.browse(cr, uid, coda_statement.coda_id.id, context=context).statement_ids]
# unlink CODA banks statements as well as associated bank statements and CODA files
# unlink CODA banks statements as well as associated bank statements and CODA files
for coda_statement in self.browse(cr, uid, new_ids, context=context):
if coda_statement.statement_id.state == 'confirm':
raise osv.except_osv(_('Invalid Action!'),
_("Cannot delete CODA Bank Statement '%s' of journal '%s'." \
"\nThe associated Bank Statement has already been confirmed." \
"\nPlease undo this action first.") \
if coda_statement.statement_id.state == 'confirm':
raise osv.except_osv(_('Invalid action !'),
_("Cannot delete CODA Bank Statement '%s' of Journal '%s'." \
"\nThe associated Bank Statement has already been confirmed !" \
"\nPlease undo this action first!") \
% (coda_statement.name, coda_statement.journal_id.name))
else:
if not context.get('coda_unlink', False):
@ -311,11 +335,11 @@ class coda_bank_statement(osv.osv):
coda_obj.unlink(cr, uid, [coda_statement.coda_id.id], context=context)
if not context.get('bank_statement_unlink', False):
if coda_statement.statement_id and bank_st_obj.exists(cr, uid, coda_statement.statement_id.id, context=context):
bank_st_obj.unlink(cr, uid, [coda_statement.statement_id.id], context=context)
bank_st_obj.unlink(cr, uid, [coda_statement.statement_id.id], context=context)
context.update({'coda_statement_unlink': False})
return super(coda_bank_statement, self).unlink(cr, uid, new_ids, context=context)
coda_bank_statement()
class account_bank_statement(osv.osv):
@ -323,7 +347,10 @@ class account_bank_statement(osv.osv):
_columns = {
'coda_statement_id': fields.many2one('coda.bank.statement', 'Associated CODA Bank Statement'),
}
_sql_constraints = [
('name_company_uniq', 'unique (name,company_id)', 'The name of the Bank Statement must be unique per company !')
]
def unlink(self, cr, uid, ids, context=None):
if context is None:
context = {}
@ -332,15 +359,15 @@ class account_bank_statement(osv.osv):
coda_st_obj = self.pool.get('coda.bank.statement')
# find all statements that are associated with the selected bank statements via a common CODA file
ids_plus = []
ids_plus = []
for statement in self.browse(cr, uid, ids, context=context):
if statement.coda_statement_id:
for x in coda_obj.browse(cr, uid, statement.coda_statement_id.coda_id.id, context=context).statement_ids:
if x.type == 'normal':
ids_plus += [x.statement_id.id]
# unlink banks statements as well as associated CODA bank statements and CODA files
for statement in self.browse(cr, uid, ids_plus, context=context):
for statement in self.browse(cr, uid, ids_plus, context=context):
if not context.get('coda_statement_unlink', False):
if statement.coda_statement_id and coda_st_obj.exists(cr, uid, statement.coda_statement_id.id, context=context):
coda_st_obj.unlink(cr, uid, [statement.coda_statement_id.id], context=context)
@ -354,63 +381,109 @@ class account_bank_statement(osv.osv):
context.update({'bank_statement_unlink': False})
new_ids = list(set(ids + ids_plus))
return super(account_bank_statement, self).unlink(cr, uid, new_ids, context=context)
account_bank_statement()
class coda_bank_statement_line(osv.osv):
_name = 'coda.bank.statement.line'
_order = 'sequence'
_name = 'coda.bank.statement.line'
_order = 'sequence'
_description = 'CODA Bank Statement Line'
_columns = {
'name': fields.char('Communication', size=268, required=True),
'sequence': fields.integer('Sequence'),
'date': fields.date('Entry Date', required=True),
'val_date': fields.date('Valuta Date'),
'account_id': fields.many2one('account.account','Account'), # remove required=True
'val_date': fields.date('Valuta Date'),
'account_id': fields.many2one('account.account','Account'),
'type': fields.selection([
('supplier','Supplier'),
('customer','Customer'),
('general','General'),
('globalisation','Globalisation'),
('information','Information'),
('communication','Free Communication'),
('globalisation','Globalisation'),
('information','Information'),
('communication','Free Communication'),
], 'Type', required=True),
'globalisation_level': fields.integer('Globalisation Level',
help="The value which is mentioned (1 to 9), specifies the hierarchy level"
" of the globalisation of which this record is the first."
"\nThe same code will be repeated at the end of the globalisation."),
'globalisation_amount': fields.float('Globalisation Amount', digits_compute=dp.get_precision('Account')),
'globalisation_level': fields.integer('Globalisation Level',
help="The value which is mentioned (1 to 9), specifies the hierarchy level"
" of the globalisation of which this record is the first."
"\nThe same code will be repeated at the end of the globalisation."),
'globalisation_amount': fields.float('Globalisation Amount', digits_compute=dp.get_precision('Account')),
'globalisation_id': fields.many2one('account.bank.statement.line.global', 'Globalisation ID', readonly=True,
help="Code to identify transactions belonging to the same globalisation level within a batch payment"),
help="Code to identify transactions belonging to the same globalisation level within a batch payment"),
'amount': fields.float('Amount', digits_compute=dp.get_precision('Account')),
'partner_id': fields.many2one('res.partner', 'Partner'),
'counterparty_name': fields.char('Counterparty Name', size=35),
'counterparty_bic': fields.char('Counterparty BIC', size=11),
'counterparty_number': fields.char('Counterparty Number', size=34),
'counterparty_currency': fields.char('Counterparty Currency', size=3),
'counterparty_bic': fields.char('Counterparty BIC', size=11),
'counterparty_number': fields.char('Counterparty Number', size=34),
'counterparty_currency': fields.char('Counterparty Currency', size=3),
'payment_reference': fields.char('Payment Reference', size=35,
help="Payment Reference. For SEPA (SCT or SDD) transactions, the PaymentInformationIdentification "\
"is recorded in this field pertaining to a globalisation, and the EndToEndReference for " \
"simple transactions or for the details of a globalisation."),
'statement_id': fields.many2one('coda.bank.statement', 'CODA Bank Statement',
select=True, required=True, ondelete='cascade'),
'coda_bank_account_id': fields.related('statement_id', 'coda_bank_account_id', type='many2one', relation='coda.bank.account', string='Bank Account', store=True, readonly=True),
'ref': fields.char('Reference', size=32),
'note': fields.text('Notes'),
'company_id': fields.related('statement_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
'company_id': fields.related('statement_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
}
def unlink(self, cr, uid, ids, context=None):
if context is None:
context = {}
if context.get('block_statement_line_delete', False):
raise osv.except_osv('Warning', _('Delete operation not allowed.'))
raise osv.except_osv('Warning', _('Delete operation not allowed !'))
return super(account_bank_statement_line, self).unlink(cr, uid, ids, context=context)
coda_bank_statement_line()
coda_bank_statement_line()
class account_bank_statement_line_global(osv.osv):
_inherit = 'account.bank.statement.line.global'
_columns = {
'coda_statement_line_ids': fields.one2many('coda.bank.statement.line', 'globalisation_id', 'CODA Bank Statement Lines', readonly=True),
}
account_bank_statement_line_global()
class coda_account_mapping_rule(osv.osv):
_name = 'coda.account.mapping.rule'
_description = 'Rules Engine to assign accounts during CODA parsing'
_order = 'sequence'
_columns = {
'coda_bank_account_id': fields.many2one('coda.bank.account', 'CODA Bank Account', ondelete='cascade'),
'sequence': fields.integer('Sequence', help='Determines the order of the rules to assign accounts'),
'name': fields.char('Rule Name', size=128, required=True),
# matching criteria
'trans_type_id': fields.many2one('account.coda.trans.type', 'Transaction Type'),
'trans_family_id': fields.many2one('account.coda.trans.code', 'Transaction Family', domain=[('type', '=', 'family')]),
'trans_code_id': fields.many2one('account.coda.trans.code', 'Transaction Code', domain=[('type', '=', 'code')]),
'trans_category_id': fields.many2one('account.coda.trans.category', 'Transaction Category'),
'struct_comm_type_id': fields.many2one('account.coda.comm.type', 'Structured Communication Type'),
'partner_id': fields.many2one('res.partner', 'Partner', ondelete='cascade'),
# resulting general account
'account_id': fields.many2one('account.account', 'Account', ondelete='cascade', required=True, domain=[('type', '!=', 'view')]),
'active': fields.boolean('Active', help='Switch on/off this rule.'),
}
_defaults = {
'active': True,
}
def account_id_get(self, cr, uid, coda_bank_account_id, trans_type_id=None, trans_family_id=None,
trans_code_id=None, trans_category_id=None, struct_comm_type_id=None, partner_id=None, context=None):
cr.execute('SELECT account_id, trans_type_id, trans_family_id, trans_code_id, trans_category_id, struct_comm_type_id, partner_id ' \
'FROM coda_account_mapping_rule ' \
'WHERE active = TRUE AND coda_bank_account_id = %s ' \
'ORDER BY sequence' % coda_bank_account_id
)
rules = cr.fetchall()
condition = '(not rule[1] or (trans_type_id == rule[1])) and (not rule[2] or (trans_family_id == rule[2])) ' \
'and (not rule[3] or (trans_code_id == rule[3])) and (not rule[4] or (trans_category_id == rule[4])) ' \
'and (not rule[5] or (struct_comm_type_id == rule[5])) and (not rule[6] or (partner_id == rule[6]))'
account_id = None
for rule in rules:
if eval(condition):
account_id = rule[0]
break
return account_id
coda_account_mapping_rule()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -11,10 +11,11 @@
<field name="model">coda.bank.account</field>
<field name="arch" type="xml">
<search string="CODA Bank Account Configuration">
<field name="name" filter_domain="['|', ('name','ilike',self), ('description1','ilike',self)]" string="CODA Bank Account"/>
<filter string="Normal" domain="[('state','=','normal')]" icon="terp-folder-green"/>
<filter string="Info" domain="[('state','=','info')]" icon="terp-folder-yellow"/>
<field name="name"/>
<field name="bank_id"/>
<field name="description1"/>
<field name="journal"/>
<field name="currency" groups="base.group_multi_currency"/>
<field name="company_id" groups="base.group_multi_company"/>
@ -54,15 +55,52 @@
<field name="state" on_change="onchange_state(state)"/>
<field name="journal" attrs="{'invisible':[('state','=','info')]}"/>
<newline/>
<field name="def_payable"/>
<field name="def_receivable"/>
<field name="awaiting_account"/>
<field name="transfer_account"/>
<field name="find_payment"/>
<field name="find_bbacom"/>
<field name="find_inv_number"/>
<field name="find_partner"/>
<field name="company_id" widget='selection' groups="base.group_multi_company"/>
<field name="update_partner"/>
<field name="balance_start_enforce"/>
<field name="discard_dup"/>
<field name="active"/>
<field name="company_id" widget='selection' groups="base.group_multi_company"/>
</group>
<notebook colspan="4">
<page string="Default Accounts">
<group string="Default Account Mapping">
<field name="awaiting_account"/>
<field name="transfer_account"/>
</group>
</page>
<page string="Accounts Mapping">
<field colspan="4" name="account_mapping_ids" nolabel="1">
<tree string="Account Mapping Rules">
<field name="sequence"/>
<field name="name"/>
<field name="trans_type_id"/>
<field name="trans_family_id"/>
<field name="trans_code_id"/>
<field name="trans_category_id"/>
<field name="struct_comm_type_id"/>
<field name="partner_id"/>
<field name="account_id"/>
</tree>
<form string="Account Mapping Rules">
<field name="name"/>
<field name="account_id"/>
<field name="sequence"/>
<field name="active"/>
<separator string="Conditions" colspan="4"/>
<field name="trans_type_id"/>
<field name="trans_family_id"/>
<field name="trans_code_id"/>
<field name="trans_category_id"/>
<field name="struct_comm_type_id"/>
<field name="partner_id"/>
</form>
</field>
</page>
</notebook>
</form>
</field>
</record>
@ -282,11 +320,12 @@
<field name="name">coda.bank.statement.list</field>
<field name="model">coda.bank.statement</field>
<field name="arch" type="xml">
<tree colors="red:balance_end_real!=balance_end;blue:state=='draft' and (balance_end_real==balance_end)" string="CODA Bank Statements" create="false">
<tree colors="red:balance_end_real!=balance_end" string="CODA Bank Statements">
<field name="name"/>
<field name="date"/>
<field name="period_id"/>
<field name="coda_creation_date"/>
<field name="coda_bank_account_id"/>
<field name="old_balance_date"/>
<field name="new_balance_date"/>
<field name="balance_start"/>
<field name="balance_end_real"/>
<field name="balance_end"/>
@ -299,61 +338,56 @@
<field name="name">coda.bank.statement.form</field>
<field name="model">coda.bank.statement</field>
<field name="arch" type="xml">
<form string="CODA Bank Statement" version="7.0" create="false">
<sheet>
<group col="4">
<field name="name"/>
<field name="date"/>
<field name="coda_bank_account_id"/>
<field name="currency" groups="base.group_multi_currency"/>
<field name="period_id"/>
<field name="type"/>
<newline/>
<field name="balance_start"/>
<field name="balance_end_real"/>
</group>
<notebook>
<page string="Transactions">
<field name="line_ids">
<tree string="CODA Statement Lines">
<field name="sequence" string="Seq"/>
<field name="date"/>
<field name="val_date"/>
<field name="ref"/>
<field name="name" width="250"/>
<field name="type"/>
<field name="partner_id"/>
<field name="account_id"/>
<field name="amount"/>
<field name="globalisation_amount" string="Glob. Amount"/>
<field name="globalisation_id" string="Glob. Id"/>
</tree>
<form string="CODA Statement Lines" version="7.0">
<group col="4">
<field name="sequence" string="Seq"/>
<field name="date"/>
<field name="val_date"/>
<field name="name"/>
<field name="type"/>
<field name="partner_id"/>
<field domain="[('type', '&lt;&gt;', 'view')]" name="account_id"/>
<field name="amount"/>
<field name="ref"/>
<field name="globalisation_amount"/>
<field name="globalisation_level"/>
<field name="globalisation_id"/>
</group>
<separator string="Notes"/>
<field name="note"/>
</form>
</field>
</page>
</notebook>
<group colspan="4">
<field name="balance_end"/>
</group>
</sheet>
</form>
<form string="CODA Bank Statement">
<field name="name"/>
<field name="coda_creation_date"/>
<field name="coda_bank_account_id"/>
<field name="currency"/>
<field name="type"/>
<newline/>
<field name="balance_start"/>
<field name="balance_end_real"/>
<field name="old_balance_date"/>
<field name="new_balance_date"/>
<notebook colspan="4">
<page string="Transactions">
<field colspan="4" name="line_ids" nolabel="1">
<tree string="CODA Statement Lines">
<field name="sequence" string="Seq"/>
<field name="date"/>
<field name="val_date"/>
<field name="ref"/>
<field name="name" width="250"/>
<field name="type"/>
<field name="partner_id"/>
<field name="account_id"/>
<field name="amount"/>
<field name="globalisation_amount" string="Glob. Amount"/>
<field name="globalisation_id" string="Glob. Id"/>
</tree>
<form string="CODA Statement Lines">
<field name="sequence" string="Seq"/>
<field name="date"/>
<field name="val_date"/>
<field name="name"/>
<field name="type"/>
<field name="partner_id"/>
<field domain="[('type', '&lt;&gt;', 'view')]" name="account_id"/>
<field name="amount"/>
<field name="ref"/>
<field name="globalisation_amount"/>
<field name="globalisation_level"/>
<field name="globalisation_id"/>
<separator colspan="4" string="Notes"/>
<field colspan="4" name="note" nolabel="1"/>
</form>
</field>
</page>
</notebook>
<group colspan="4">
<field name="balance_end"/>
</group>
</form>
</field>
</record>
@ -362,10 +396,12 @@
<field name="model">coda.bank.statement</field>
<field name="arch" type="xml">
<search string="Search CODA Bank Statements">
<field name="name" string="CODA Bank Statement"/>
<field name="date"/>
<filter string="Normal" domain="[('type','=','normal')]" icon="terp-folder-green"/>
<filter string="Info" domain="[('type','=','info')]" icon="terp-folder-yellow"/>
<field name="name"/>
<field name="coda_creation_date"/>
<field name="old_balance_date"/>
<field name="new_balance_date"/>
<field name="period_id"/>
<field name="coda_bank_account_id"/>
<field name="journal_id" domain="[('type', '=', 'bank')]"/>
@ -457,6 +493,7 @@
<field name="amount"/>
<field name="globalisation_amount" string="Glob. Amount"/>
<field name="type"/>
<field name="ref"/>
<field name="note"/>
</group>
<newline/>

33
addons/l10n_be_coda/res_bank.py Executable file
View File

@ -0,0 +1,33 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2012 Noviat nv/sa (www.noviat.be). All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
class res_bank(osv.osv):
_inherit = 'res.bank'
_columns = {
'code': fields.char('Code', size=3,
help='Country specific Bank Code (used for bban to iban conversion).'),
}
res_bank()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_res_bank_form_add_code" model="ir.ui.view">
<field name="name">res.bank.form.add.code</field>
<field name="model">res.bank</field>
<field name="inherit_id" ref="base.view_res_bank_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="active" position="after">
<field name="code" select="1"/>
</field>
</field>
</record>
<record id="view_res_bank_tree_add_code" model="ir.ui.view">
<field name="name">res.bank.tree.add.code</field>
<field name="model">res.bank</field>
<field name="inherit_id" ref="base.view_res_bank_tree"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="country" position="after">
<field name="code"/>
</field>
</field>
</record>
</data>
</openerp>

File diff suppressed because it is too large Load Diff