diff --git a/account_usability/__openerp__.py b/account_usability/__openerp__.py index b62613b..c795a17 100644 --- a/account_usability/__openerp__.py +++ b/account_usability/__openerp__.py @@ -23,7 +23,7 @@ { 'name': 'Account Usability', - 'version': '0.1', + 'version': '0.2', 'category': 'Accounting & Finance', 'license': 'AGPL-3', 'summary': 'Small usability enhancements in account module', diff --git a/account_usability/account.py b/account_usability/account.py index 1b6d30d..e214035 100644 --- a/account_usability/account.py +++ b/account_usability/account.py @@ -62,6 +62,23 @@ class AccountInvoice(models.Model): res['value']['period_id'] = False 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): _inherit = 'account.fiscalyear' diff --git a/account_usability/migrations/8.0.0.2/pre-migration.py b/account_usability/migrations/8.0.0.2/pre-migration.py new file mode 100644 index 0000000..1b21694 --- /dev/null +++ b/account_usability/migrations/8.0.0.2/pre-migration.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +# © 2016 Akretion (Alexis de Lattre ) +# 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'))")