You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.2 KiB

  1. # Copyright 2020 Camptocamp SA
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
  3. from odoo import models
  4. class AccountBankStatementImport(models.TransientModel):
  5. _inherit = "account.bank.statement.import"
  6. def _create_bank_statements(self, stmts_vals):
  7. """ Create additional line in statement to set bank statement statement
  8. to 0 balance"""
  9. statement_ids, notifications = super()._create_bank_statements(stmts_vals)
  10. statements = self.env['account.bank.statement'].browse(statement_ids)
  11. for statement in statements:
  12. amount = sum(statement.line_ids.mapped("amount"))
  13. if statement.journal_id.transfer_line:
  14. if amount != 0:
  15. amount = -amount
  16. statement.line_ids.create(
  17. {
  18. "name": statement.name,
  19. "amount": amount,
  20. "statement_id": statement.id,
  21. "date": statement.date,
  22. }
  23. )
  24. statement.balance_end_real = statement.balance_start
  25. else:
  26. statement.balance_end_real = statement.balance_start + amount
  27. return statement_ids, notifications