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.1 KiB

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