[FIX] account: usability of entry sequences.

This revert commits 51882ea70c and d94c449547 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().
This commit is contained in:
qdp-odoo
2017-03-27 12:10:08 +02:00
parent 70b770d62e
commit 5a7db15aff
2 changed files with 11 additions and 2 deletions
+10 -1
View File
@@ -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,
+1 -1
View File
@@ -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)]" />