Skip to content

Commit

Permalink
[FIX] l10n_fr_certification: write on move should a little bit more d…
Browse files Browse the repository at this point in the history
…efensive

Before this commit, we tried to assign new hash and seq number bu the method
obj.key = new value which triggers a write on obj, and we find ourselves in a loop

After this commit, first only moves that do not have hash and sequence number are selected
and second, super.write is called to avoid getting back in our very same write function

Development issue by PNA and LAP on bank statements validation
  • Loading branch information
kebeclibre committed May 23, 2017
1 parent 0a74ed9 commit c24a0ab
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions addons/l10n_fr_certification/models/account.py
Expand Up @@ -80,10 +80,12 @@ def write(self, vals):
res = super(AccountMove, self).write(vals)
# write the hash and the secure_sequence_number when posting an account.move
if has_been_posted:
for move in self.filtered(lambda m: m.company_id.country_id.code == 'FR'):
for move in self.filtered(lambda m: m.company_id.country_id.code == 'FR' and
not (m.l10n_fr_secure_sequence_number or m.l10n_fr_hash)):
new_number = move.company_id.l10n_fr_secure_sequence_id.next_by_id()
move.l10n_fr_secure_sequence_number = new_number
move.l10n_fr_hash = move._get_new_hash(new_number)
vals_hashing = {'l10n_fr_secure_sequence_number': new_number,
'l10n_fr_hash': move._get_new_hash(new_number)}
res |= super(AccountMove, move).write(vals_hashing)
return res

def button_cancel(self):
Expand Down

0 comments on commit c24a0ab

Please sign in to comment.