From a22148329ff3ecef97f13b28d0db46aee2d3c528 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 12 Jan 2017 17:59:20 +0100 Subject: [PATCH] Port to v10 the code that re-gen the name of move lines Empty ref on move generated from bank statement, because it has unuseful info (and redundant) --- .../account_bank_statement_import.py | 1 - .../account_view.xml | 6 +++ account_usability/account.py | 40 +++++++++++++------ 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/account_bank_statement_import_usability/account_bank_statement_import.py b/account_bank_statement_import_usability/account_bank_statement_import.py index 0fd9886..84c9b69 100644 --- a/account_bank_statement_import_usability/account_bank_statement_import.py +++ b/account_bank_statement_import_usability/account_bank_statement_import.py @@ -7,7 +7,6 @@ from odoo import models, api class AccountBankStatementImport(models.TransientModel): - """Extend model account.bank.statement.""" _inherit = 'account.bank.statement.import' def _check_journal_bank_account(self, journal, account_number): diff --git a/account_bank_statement_import_usability/account_view.xml b/account_bank_statement_import_usability/account_view.xml index eba8310..16f1151 100644 --- a/account_bank_statement_import_usability/account_view.xml +++ b/account_bank_statement_import_usability/account_view.xml @@ -7,6 +7,11 @@ + bank_statement_import_usability.account.bank.statement.tree diff --git a/account_usability/account.py b/account_usability/account.py index 72fcbbd..3c7d197 100644 --- a/account_usability/account.py +++ b/account_usability/account.py @@ -43,18 +43,17 @@ class AccountInvoice(models.Model): # write a rubbish '/' in it ! # 2) the 'name' field of the account.move.line is used in the overdue letter, # and '/' is not meaningful for our customer ! - # TODO port to v10 - #@api.multi - #def action_number(self): - # res = super(AccountInvoice, self).action_number() - # for inv in self: - # self._cr.execute( - # "UPDATE account_move_line SET name= " - # "CASE WHEN name='/' THEN %s " - # "ELSE %s||' - '||name END " - # "WHERE move_id=%s", (inv.number, inv.number, inv.move_id.id)) - # self.invalidate_cache() - # return res + @api.multi + def action_move_create(self): + res = super(AccountInvoice, self).action_move_create() + for inv in self: + self._cr.execute( + "UPDATE account_move_line SET name= " + "CASE WHEN name='/' THEN %s " + "ELSE %s||' - '||name END " + "WHERE move_id=%s", (inv.number, inv.number, inv.move_id.id)) + self.invalidate_cache() + return res class AccountInvoiceLine(models.Model): @@ -219,6 +218,23 @@ class AccountBankStatementLine(models.Model): # search_reconciliation_proposition=search_rec_prop, # context=context) + def _prepare_reconciliation_move(self, move_ref): + vals = super(AccountBankStatementLine, self).\ + _prepare_reconciliation_move(move_ref) + # By default, ref contains the name of the statement + name of the + # statement line. It causes 2 problems: + # 1) The 'ref' field is too big + # 2) The name of the statement line is already written in the name of + # the move line -> not useful to have the info 2 times + # In the end, I think it's better to just put nothing (we could write + # the name of the statement which has the account number, but it doesn't + # bring any useful info to the accountant) + # The only "good" thing to do would be to have a sequence per + # statement line and write it in this 'ref' field + # But that would required an additionnal field on statement lines + vals['ref'] = False + return vals + @api.multi def show_account_move(self): self.ensure_one()