OCA / account-financial-tools

Odoo Accountant Financial Tools and Utils
GNU Affero General Public License v3.0
300 stars 741 forks source link

[FIX] account_journal_general_sequence: provide defaults for sorting #1840

Closed yajo closed 3 months ago

yajo commented 3 months ago

Under some weird scenarios where some modules are involved, several invoices are posted at the same time, and no invoice exists, we could get to the case when one.date or one.name were False.

Here I provide a default value to avoid comparing str to bool in those cases.

Tried a lot but couldn't reproduce the test case in code, sorry 😕. However, the traceback was clear:

File "/opt/odoo/auto/addons/account_journal_general_sequence/models/account_move.py", line 64, in _compute_entry_number
  for move in chosen.sorted(lambda one: (one.date, one.name, one.id)):
File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5583, in sorted
  ids = tuple(item.id for item in sorted(self, key=key, reverse=reverse))
TypeError: '<' not supported between instances of 'str' and 'bool'

@moduon MT-5559

edlopen commented 3 months ago

LGTM @yajo !

yajo commented 3 months ago

/ocabot merge patch

El mar, 26 mar 2024 a las 7:48, Eduardo López Peñalver (< @.***>) escribió:

LGTM @yajo https://github.com/yajo !

— Reply to this email directly, view it on GitHub https://github.com/OCA/account-financial-tools/pull/1840#issuecomment-2019627249, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHNXDPHF64U35FYTHCGC4DY2EK4PAVCNFSM6AAAAABFGYZ4TCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJZGYZDOMRUHE . You are receiving this because you were mentioned.Message ID: @.***>

OCA-git-bot commented 3 months ago

This PR looks fantastic, let's merge it! Prepared branch 16.0-ocabot-merge-pr-1840-by-yajo-bump-patch, awaiting test results.

OCA-git-bot commented 3 months ago

Congratulations, your PR was merged at 87fb342816692d8a1c4f018419f0028a933dfa3f. Thanks a lot for contributing to OCA. ❤️