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

# -*- coding: utf-8 -*-
# Copyright 2017 Tecnativa - Luis M. Ontalba
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from odoo import api, models
class AccountMoveLine(models.Model):
_inherit = 'account.move.line'
@api.multi
def _prepare_statement_line_vals(self, statement):
self.ensure_one()
assert statement, 'Missing statement'
amount = 0.0
if self.debit > 0:
amount = self.debit
elif self.credit > 0:
amount = -self.credit
vals = {
'name': self.name or '?',
'amount': amount,
'partner_id': self.partner_id.id,
'statement_id': statement.id,
'ref': self.ref,
'date': self.date_maturity,
'amount_currency': self.amount_currency,
'currency_id': self.currency_id.id,
}
return vals
@api.multi
def create_statement_line_from_move_line(self, statement):
abslo = self.env['account.bank.statement.line']
for mline in self:
abslo.create(mline._prepare_statement_line_vals(statement))
return