diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 0301d64db11..a6edaff4967 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -439,6 +439,15 @@ class account_bank_statement(osv.osv): class account_bank_statement_line(osv.osv): + def unlink(self, cr, uid, ids, context=None): + for item in self.browse(cr, uid, ids, context=context): + if item.journal_entry_id: + raise osv.except_osv( + _('Invalid Action!'), + _('In order to delete a bank statement line, you must first cancel it to delete related journal items.') + ) + return super(account_bank_statement_line, self).unlink(cr, uid, ids, context=context) + def cancel(self, cr, uid, ids, context=None): account_move_obj = self.pool.get('account.move') move_ids = [] @@ -522,7 +531,7 @@ class account_bank_statement_line(osv.osv): 'statement_id': line.statement_id.id, 'account_code': line.journal_id.default_debit_account_id.code, 'account_name': line.journal_id.default_debit_account_id.name, - 'partner_name': line.partner_id.name, + 'partner_name': line.partner_id and line.partner_id.name or line.partner_name, 'amount_currency_str': amount_currency_str, 'has_no_partner': not line.partner_id.id, } @@ -533,9 +542,7 @@ class account_bank_statement_line(osv.osv): return data def search_structured_com(self, cr, uid, st_line, context=None): - if not st_line.ref: - return - domain = [('ref', '=', st_line.ref)] + domain = [('ref', '=', st_line.name.replace('/', ''))] if st_line.partner_id: domain += [('partner_id', '=', st_line.partner_id.id)] ids = self.pool.get('account.move.line').search(cr, uid, domain, limit=1, context=context) @@ -600,14 +607,13 @@ class account_bank_statement_line(osv.osv): """ mv_line_pool = self.pool.get('account.move.line') - domain = additional_domain + [('reconcile_id', '=', False),('state', '=', 'valid')] + domain = additional_domain + [('reconcile_id', '=', False), ('state', '=', 'valid')] if st_line.partner_id.id: domain += [('partner_id', '=', st_line.partner_id.id), '|', ('account_id.type', '=', 'receivable'), ('account_id.type', '=', 'payable')] else: - domain += [('account_id.reconcile', '=', True)] - #domain += [('account_id.reconcile', '=', True), ('account_id.type', '=', 'other')] + domain += [('account_id.reconcile', '=', True), ('account_id.type', '=', 'other')] if excluded_ids: domain.append(('id', 'not in', excluded_ids)) line_ids = mv_line_pool.search(cr, uid, domain, order="date_maturity asc, id asc", context=context) @@ -829,7 +835,7 @@ class account_bank_statement_line(osv.osv): _description = "Bank Statement Line" _inherit = ['ir.needaction_mixin'] _columns = { - 'name': fields.char('Description', required=True), + 'name': fields.char('Communication', required=True), 'date': fields.date('Date', required=True), 'amount': fields.float('Amount', digits_compute=dp.get_precision('Account')), 'partner_id': fields.many2one('res.partner', 'Partner'), @@ -837,7 +843,8 @@ class account_bank_statement_line(osv.osv): 'account_id': fields.many2one('account.account', 'Account', help="This technical field can be used at the statement line creation/import time in order to avoid the reconciliation process on it later on. The statement line will simply create a counterpart on this account"), 'statement_id': fields.many2one('account.bank.statement', 'Statement', select=True, required=True, ondelete='cascade'), 'journal_id': fields.related('statement_id', 'journal_id', type='many2one', relation='account.journal', string='Journal', store=True, readonly=True), - 'ref': fields.char('Structured Communication'), + 'partner_name': fields.char('Partner Name', help="This field is used to record the third party name when importing bank statement in electronic format, when the partner doesn't exist yet in the database (or cannot be found)."), + 'ref': fields.char('Reference'), 'note': fields.text('Notes'), 'sequence': fields.integer('Sequence', select=True, help="Gives the sequence order when displaying a list of bank statement lines."), 'company_id': fields.related('statement_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True), diff --git a/addons/account/demo/account_bank_statement.xml b/addons/account/demo/account_bank_statement.xml index b79d8b95cd6..aec70da0097 100644 --- a/addons/account/demo/account_bank_statement.xml +++ b/addons/account/demo/account_bank_statement.xml @@ -26,11 +26,11 @@ - SAJ2014002 + - SAJ/2014/002 + SAJ2014002 diff --git a/addons/account/static/src/js/account_widgets.js b/addons/account/static/src/js/account_widgets.js index c9bdaac7071..889538cedb4 100644 --- a/addons/account/static/src/js/account_widgets.js +++ b/addons/account/static/src/js/account_widgets.js @@ -768,10 +768,10 @@ openerp.account = function (instance) { line.q_amount = (line.debit !== 0 ? "- "+line.q_debit : "") + (line.credit !== 0 ? line.q_credit : ""); line.q_popover = QWeb.render("bank_statement_reconciliation_move_line_details", {line: line}); line.q_label = line.name; + if (line.has_no_partner){ line.q_label = line.partner_name + ': ' +line.q_label; } - // WARNING : pretty much of a ugly hack // The value of account_move.ref is either the move's communication or it's name without the slashes if (line.ref && line.ref !== line.name.replace(/\//g,'')) diff --git a/addons/account/static/src/xml/account_bank_statement_reconciliation.xml b/addons/account/static/src/xml/account_bank_statement_reconciliation.xml index 2c410404a4d..83680f005e3 100644 --- a/addons/account/static/src/xml/account_bank_statement_reconciliation.xml +++ b/addons/account/static/src/xml/account_bank_statement_reconciliation.xml @@ -53,7 +53,7 @@ @@ -61,7 +61,8 @@ - diff --git a/addons/l10n_be_coda/wizard/account_coda_import.py b/addons/l10n_be_coda/wizard/account_coda_import.py index ad21a780611..929179873d7 100644 --- a/addons/l10n_be_coda/wizard/account_coda_import.py +++ b/addons/l10n_be_coda/wizard/account_coda_import.py @@ -59,6 +59,7 @@ class account_coda_import(osv.osv_memory): return {} recordlist = unicode(base64.decodestring(codafile), 'windows-1252', 'strict').split('\n') statements = [] + globalisation_comm = {} for line in recordlist: if not line: pass @@ -69,7 +70,6 @@ class account_coda_import(osv.osv_memory): statement['version'] = line[127] if statement['version'] not in ['1', '2']: raise osv.except_osv(_('Error') + ' R001', _('CODA V%s statements are not supported, please contact your bank') % statement['version']) - statement['globalisation_stack'] = [] statement['lines'] = [] statement['date'] = time.strftime(tools.DEFAULT_SERVER_DATE_FORMAT, time.strptime(rmspaces(line[5:11]), '%d%m%y')) statement['separateApplication'] = rmspaces(line[83:88]) @@ -154,16 +154,11 @@ class account_coda_import(osv.osv_memory): statementLine['entryDate'] = time.strftime(tools.DEFAULT_SERVER_DATE_FORMAT, time.strptime(rmspaces(line[115:121]), '%d%m%y')) statementLine['type'] = 'normal' statementLine['globalisation'] = int(line[124]) - if len(statement['globalisation_stack']) > 0 and statementLine['communication'] != '': - statementLine['communication'] = "\n".join([statement['globalisation_stack'][-1]['communication'], statementLine['communication']]) if statementLine['globalisation'] > 0: - if len(statement['globalisation_stack']) > 0 and statement['globalisation_stack'][-1]['globalisation'] == statementLine['globalisation']: - # Destack - statement['globalisation_stack'].pop() - else: - #Stack - statementLine['type'] = 'globalisation' - statement['globalisation_stack'].append(statementLine) + statementLine['type'] = 'globalisation' + globalisation_comm[statementLine['ref_move']] = statementLine['communication'] + if not statementLine.get('communication'): + statementLine['communication'] = globalisation_comm.get(statementLine['ref_move'], '') statement['lines'].append(statementLine) elif line[1] == '2': if statement['lines'][-1]['ref'][0:4] != line[2:6]: @@ -290,7 +285,6 @@ class account_coda_import(osv.osv_memory): if 'counterpartyAddress' in line and line['counterpartyAddress'] != '': note.append(_('Counter Party Address') + ': ' + line['counterpartyAddress']) - line['name'] = "\n".join(filter(None, [line['counterpartyName'], line['communication']])) partner_id = None structured_com = "" bank_account_id = False @@ -311,16 +305,17 @@ class account_coda_import(osv.osv_memory): except ValueError: bank_code = 'bank' bank_account_id = self.pool.get('res.partner.bank').create(cr, uid, {'acc_number': str(line['counterpartyNumber']), 'state': bank_code}, context=context) - if 'communication' in line and line['communication'] != '': + if line.get('communication', ''): note.append(_('Communication') + ': ' + line['communication']) data = { - 'name': line['name'], + 'name': structured_com or line['communication'], 'note': "\n".join(note), 'date': line['entryDate'], 'amount': line['amount'], 'partner_id': partner_id, + 'partner_name': line['counterpartyName'], 'statement_id': statement['id'], - 'ref': structured_com, + 'ref': line['ref'], 'sequence': line['sequence'], 'bank_account_id': bank_account_id, }
- +
+ : + ()