Better name field in account.move.line for move generated from customer invoice (WARNING : migration script included)
This commit is contained in:
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Account Usability',
|
'name': 'Account Usability',
|
||||||
'version': '0.1',
|
'version': '0.2',
|
||||||
'category': 'Accounting & Finance',
|
'category': 'Accounting & Finance',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'summary': 'Small usability enhancements in account module',
|
'summary': 'Small usability enhancements in account module',
|
||||||
|
|||||||
@@ -62,6 +62,23 @@ class AccountInvoice(models.Model):
|
|||||||
res['value']['period_id'] = False
|
res['value']['period_id'] = False
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
# I really hate to see a "/" in the 'name' field of the account.move.line
|
||||||
|
# generated from customer invoices linked to the partners' account because:
|
||||||
|
# 1) the label of an account move line is an important field, we can't
|
||||||
|
# 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 !
|
||||||
|
@api.multi
|
||||||
|
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=%s WHERE "
|
||||||
|
"move_id=%s AND name='/'", (inv.number, inv.move_id.id))
|
||||||
|
self.invalidate_cache()
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
class AccountFiscalYear(models.Model):
|
class AccountFiscalYear(models.Model):
|
||||||
_inherit = 'account.fiscalyear'
|
_inherit = 'account.fiscalyear'
|
||||||
|
|||||||
14
account_usability/migrations/8.0.0.2/pre-migration.py
Normal file
14
account_usability/migrations/8.0.0.2/pre-migration.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# -*- 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=ref WHERE name='/' "
|
||||||
|
"AND ref is not null AND journal_id in "
|
||||||
|
"(SELECT id FROM account_journal WHERE type in ('sale', 'sale_refund'))")
|
||||||
Reference in New Issue
Block a user