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.

36 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. assert statement, 'Missing statement'
  10. amount = 0.0
  11. if self.debit > 0:
  12. amount = self.debit
  13. elif self.credit > 0:
  14. amount = -self.credit
  15. vals = {
  16. 'name': self.name or '?',
  17. 'amount': amount,
  18. 'partner_id': self.partner_id.id,
  19. 'statement_id': statement.id,
  20. 'ref': self.ref,
  21. 'date': self.date_maturity,
  22. 'amount_currency': self.amount_currency,
  23. 'currency_id': self.currency_id.id,
  24. }
  25. return vals
  26. @api.multi
  27. def create_statement_line_from_move_line(self, statement):
  28. abslo = self.env['account.bank.statement.line']
  29. for mline in self:
  30. abslo.create(mline._prepare_statement_line_vals(statement))
  31. return