From 5a7db15aff7d88d689bf5f4e0d08dedff954ba6e Mon Sep 17 00:00:00 2001 From: qdp-odoo Date: Mon, 27 Mar 2017 12:10:08 +0200 Subject: [PATCH] [FIX] account: usability of entry sequences. This revert commits 51882ea70cb599aec8b424b0bde4edc425299c36 and d94c449547a2a7a6e270e4602320f588c5b6f896 that were introduced to solve OPW-693955. The usability before those fixes was good, but the bug was appearing when we first create the journal without the boolean 'dedicated refund sequence' set, then we try to modify that va$ This time, the fix consist to create automatically the sequence on the write of the boolean if it's not existing yet, in the same fashion than on the create(). --- addons/account/models/account.py | 11 ++++++++++- addons/account/views/account_view.xml | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account.py b/addons/account/models/account.py index cbdc746302e..0a07026443e 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -345,6 +345,15 @@ class AccountJournal(models.Model): if 'bank_acc_number' in vals: for journal in self.filtered(lambda r: r.type == 'bank' and not r.bank_account_id): journal.set_bank_account(vals.get('bank_acc_number'), vals.get('bank_id')) + # create the relevant refund sequence + if vals.get('refund_sequence'): + for journal in self.filtered(lambda j: j.type in ('sale', 'purchase') and not j.refund_sequence_id): + journal_vals = { + 'name': journal.name, + 'company_id': journal.company_id.id, + 'code': journal.code + } + journal.refund_sequence_id = self.sudo()._create_sequence(journal_vals, refund=True).id return result @@ -360,7 +369,7 @@ class AccountJournal(models.Model): """ Create new no_gap entry sequence for every new Journal""" prefix = self._get_sequence_prefix(vals['code'], refund) seq = { - 'name': vals['name'], + 'name': refund and vals['name'] + _(': Refund') or vals['name'], 'implementation': 'no_gap', 'prefix': prefix, 'padding': 4, diff --git a/addons/account/views/account_view.xml b/addons/account/views/account_view.xml index 0658be752d7..0f748b89371 100644 --- a/addons/account/views/account_view.xml +++ b/addons/account/views/account_view.xml @@ -282,7 +282,7 @@ - +