summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorqdp-odoo <qdp@odoo.com>2017-03-27 12:10:08 +0200
committerqdp-odoo <qdp@odoo.com>2017-03-27 12:10:08 +0200
commit5a7db15aff7d88d689bf5f4e0d08dedff954ba6e (patch)
treef6c70f4a1295cda192d8d8b0d85934792666c86b
parent70b770d62e53e55075daef20674a7efaaf85655c (diff)
[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().
-rw-r--r--addons/account/models/account.py11
-rw-r--r--addons/account/views/account_view.xml2
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 @@
<field name="code"/>
<field name="refund_sequence" attrs="{'invisible': [('type', 'not in', ['sale', 'purchase'])]}" groups="base.group_no_one"/>
<field name="sequence_id" required="0" attrs="{'readonly': 1}" groups="base.group_no_one"/>
- <field name="refund_sequence_id" attrs="{'invisible': ['|',('type', 'not in', ['sale', 'purchase']), ('refund_sequence', '!=', True)], 'required': [('type', 'in', ['sale', 'purchase']), ('refund_sequence', '=', True)]}"/>
+ <field name="refund_sequence_id" required="0" attrs="{'readonly': 1, 'invisible': ['|',('type', 'not in', ['sale', 'purchase']), ('refund_sequence', '!=', True)]}" groups="base.group_no_one"/>
</group>
<group>
<field name="default_debit_account_id" domain="[('deprecated', '=', False)]" />