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.

37 lines
1.1 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2017 Tecnativa - Luis M. Ontalba
  3. # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
  4. from odoo import api, models
  5. class AccountMoveLine(models.Model):
  6. _inherit = 'account.move.line'
  7. @api.multi
  8. def _prepare_statement_line_vals(self, statement):
  9. self.ensure_one()
  10. assert statement, 'Missing statement'
  11. amount = 0.0
  12. if self.debit > 0:
  13. amount = self.debit
  14. elif self.credit > 0:
  15. amount = -self.credit
  16. vals = {
  17. 'name': self.name or '?',
  18. 'amount': amount,
  19. 'partner_id': self.partner_id.id,
  20. 'statement_id': statement.id,
  21. 'ref': self.ref,
  22. 'date': self.date_maturity,
  23. 'amount_currency': self.amount_currency,
  24. 'currency_id': self.currency_id.id,
  25. }
  26. return vals
  27. @api.multi
  28. def create_statement_line_from_move_line(self, statement):
  29. abslo = self.env['account.bank.statement.line']
  30. for mline in self:
  31. abslo.create(mline._prepare_statement_line_vals(statement))
  32. return