Skip to content

Commit

Permalink
[FIX] l10n_do_accounting: fix invoice number with wrong sequence in BBDD
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge-C0 committed Jul 12, 2024
1 parent 600da9f commit a2f1c49
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion l10n_do_accounting/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"category": "Localization",
"license": "LGPL-3",
"website": "https://github.com/odoo-dominicana",
"version": "15.0.0.14.5",
"version": "15.0.0.14.6",
# any module necessary for this one to work correctly
"depends": ["l10n_latam_invoice_document", "l10n_do"],
# always loaded
Expand Down
2 changes: 1 addition & 1 deletion l10n_do_accounting/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,5 +1035,5 @@ def _deduce_sequence_number_reset(self, name):
elif self._context.get("is_l10n_do_seq", False):
return "never"
else:
"never"
return "never"
return super(AccountMove, self)._deduce_sequence_number_reset(name)
24 changes: 24 additions & 0 deletions l10n_do_accounting/models/monkey_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,27 @@ def date_key(move):
and not x.l10n_do_fiscal_number
):
move.with_context(is_l10n_do_seq=True)._set_next_sequence()

def _set_next_sequence(self):
self.ensure_one()

super(AccountMove, self)._set_next_sequence()

if not self._context.get("is_l10n_do_seq", False):
last_sequence = self._get_last_sequence()

if last_sequence != None:

Check failure on line 113 in l10n_do_accounting/models/monkey_patch.py

View workflow job for this annotation

GitHub Actions / flake8

comparison to None should be 'if cond is not None:'

Check failure on line 113 in l10n_do_accounting/models/monkey_patch.py

View workflow job for this annotation

GitHub Actions / flake8

comparison to None should be 'if cond is not None:'

new_seq_year = not "/" + str(self.date.year) + "/" in last_sequence
if new_seq_year:
last_sequence = self._get_last_sequence(relaxed=True) or self._get_starting_sequence()

format, format_values = self._get_sequence_format_param(last_sequence)
if new_seq_year:
format_values['seq'] = 0
format_values['year'] = self[self._sequence_date_field].year % (10 ** format_values['year_length'])
format_values['month'] = self[self._sequence_date_field].month
format_values['seq'] = format_values['seq'] + 1

self[self._sequence_field] = format.format(**format_values)
self._compute_split_sequence()

0 comments on commit a2f1c49

Please sign in to comment.