Skip to content

Commit

Permalink
[FIX] account_statement_base: Allow add lines from bank statment form…
Browse files Browse the repository at this point in the history
… view

TT50906
  • Loading branch information
victoralmau authored and Daemo00 committed Oct 6, 2024
1 parent 4a29f76 commit 7941601
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions account_statement_base/models/account_bank_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@
class AccountBankStatement(models.Model):
_inherit = "account.bank.statement"

# TODO: Delete if merged https://github.com/odoo/odoo/pull/182497
def _compute_date_index(self):
"""The super() method does not take into account lines that do not have
internal_index set yet, and causes sorted() to fail, we need to re-define
the method in these cases to avoid the error.
"""
_self = self
for stmt in self:
if any(not line.internal_index for line in stmt.line_ids):
_self -= stmt
sorted_lines = stmt.line_ids.filtered("internal_index").sorted(

Check warning on line 17 in account_statement_base/models/account_bank_statement.py

View check run for this annotation

Codecov / codecov/patch

account_statement_base/models/account_bank_statement.py#L16-L17

Added lines #L16 - L17 were not covered by tests
"internal_index"
)
stmt.first_line_index = sorted_lines[:1].internal_index

Check warning on line 20 in account_statement_base/models/account_bank_statement.py

View check run for this annotation

Codecov / codecov/patch

account_statement_base/models/account_bank_statement.py#L20

Added line #L20 was not covered by tests
stmt.date = sorted_lines.filtered(lambda line: line.state == "posted")[
-1:
].date
return super(AccountBankStatement, _self)._compute_date_index()

def action_open_statement_lines(self):
self.ensure_one()
if not self:
Expand Down

0 comments on commit 7941601

Please sign in to comment.