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)
This commit is contained in:
Alexis de Lattre
2017-01-12 17:59:20 +01:00
parent b2a96f4db2
commit a22148329f
3 changed files with 34 additions and 13 deletions

View File

@@ -7,7 +7,6 @@ from odoo import models, api
class AccountBankStatementImport(models.TransientModel): class AccountBankStatementImport(models.TransientModel):
"""Extend model account.bank.statement."""
_inherit = 'account.bank.statement.import' _inherit = 'account.bank.statement.import'
def _check_journal_bank_account(self, journal, account_number): def _check_journal_bank_account(self, journal, account_number):

View File

@@ -7,6 +7,11 @@
<odoo> <odoo>
<!--
Let's try again to work with balance_start and balance_end_real
in v10 to see if we can work with it in v10 or not...
If we really can't, I'll re-activate this view inheritance again
<record id="view_bank_statement_form" model="ir.ui.view"> <record id="view_bank_statement_form" model="ir.ui.view">
<field name="name">bank_statement_import_usability.account.bank.statement.form</field> <field name="name">bank_statement_import_usability.account.bank.statement.form</field>
<field name="model">account.bank.statement</field> <field name="model">account.bank.statement</field>
@@ -20,6 +25,7 @@
</field> </field>
</field> </field>
</record> </record>
-->
<record id="view_bank_statement_tree" model="ir.ui.view"> <record id="view_bank_statement_tree" model="ir.ui.view">
<field name="name">bank_statement_import_usability.account.bank.statement.tree</field> <field name="name">bank_statement_import_usability.account.bank.statement.tree</field>

View File

@@ -43,18 +43,17 @@ class AccountInvoice(models.Model):
# write a rubbish '/' in it ! # write a rubbish '/' in it !
# 2) the 'name' field of the account.move.line is used in the overdue letter, # 2) the 'name' field of the account.move.line is used in the overdue letter,
# and '/' is not meaningful for our customer ! # and '/' is not meaningful for our customer !
# TODO port to v10 @api.multi
#@api.multi def action_move_create(self):
#def action_number(self): res = super(AccountInvoice, self).action_move_create()
# res = super(AccountInvoice, self).action_number() for inv in self:
# for inv in self: self._cr.execute(
# self._cr.execute( "UPDATE account_move_line SET name= "
# "UPDATE account_move_line SET name= " "CASE WHEN name='/' THEN %s "
# "CASE WHEN name='/' THEN %s " "ELSE %s||' - '||name END "
# "ELSE %s||' - '||name END " "WHERE move_id=%s", (inv.number, inv.number, inv.move_id.id))
# "WHERE move_id=%s", (inv.number, inv.number, inv.move_id.id)) self.invalidate_cache()
# self.invalidate_cache() return res
# return res
class AccountInvoiceLine(models.Model): class AccountInvoiceLine(models.Model):
@@ -219,6 +218,23 @@ class AccountBankStatementLine(models.Model):
# search_reconciliation_proposition=search_rec_prop, # search_reconciliation_proposition=search_rec_prop,
# context=context) # 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 @api.multi
def show_account_move(self): def show_account_move(self):
self.ensure_one() self.ensure_one()