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.

35 lines
1.2 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright (C) 2017 Creu Blanca
  3. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
  4. from odoo import api, fields, models
  5. class AccountBankStatementLine(models.Model):
  6. _inherit = 'account.bank.statement.line'
  7. invoice_id = fields.Many2one(
  8. 'account.invoice',
  9. string='Invoice',
  10. readonly=True
  11. )
  12. @api.multi
  13. def fast_counterpart_creation(self):
  14. for st_line in self:
  15. if not st_line.invoice_id:
  16. super(
  17. AccountBankStatementLine, st_line
  18. ).fast_counterpart_creation()
  19. else:
  20. invoice = st_line.invoice_id
  21. move_line = invoice.move_id.line_ids.filtered(
  22. lambda r: r.account_id.id == invoice.account_id.id
  23. )
  24. vals = {
  25. 'name': st_line.name,
  26. 'debit': st_line.amount < 0 and -st_line.amount or 0.0,
  27. 'credit': st_line.amount > 0 and st_line.amount or 0.0,
  28. 'move_line': move_line
  29. }
  30. st_line.process_reconciliation(counterpart_aml_dicts=[vals])