Also avoid to have '/' on move line label of supplier invoices

This commit is contained in:
Alexis de Lattre
2016-09-21 17:23:05 +02:00
parent f69c634c71
commit 0e60089010
3 changed files with 23 additions and 8 deletions

View File

@@ -23,7 +23,7 @@
{
'name': 'Account Usability',
'version': '0.2',
'version': '0.3',
'category': 'Accounting & Finance',
'license': 'AGPL-3',
'summary': 'Small usability enhancements in account module',

View File

@@ -60,13 +60,12 @@ class AccountInvoice(models.Model):
def action_number(self):
res = super(AccountInvoice, self).action_number()
for inv in self:
if inv.type in ('out_invoice', 'out_refund'):
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()
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

View File

@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
def migrate(cr, version):
if not version:
return
# cf the inherit of action_number() of account.invoice
# in account_usability/account.py
cr.execute(
"UPDATE account_move_line SET name=account_move.name "
"FROM account_move WHERE account_move_line.move_id = account_move.id "
"AND account_move_line.name='/' "
"AND account_move_line.journal_id in "
"(SELECT id FROM account_journal WHERE type in ('purchase', 'purchase_refund'))")