2
0
account-financial-tools/account_loan/models/account_move.py

33 lines
937 B
Python
Raw Normal View History

2018-02-26 12:17:24 +01:00
# Copyright 2018 Creu Blanca
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
2018-02-26 12:17:24 +01:00
class AccountMove(models.Model):
_inherit = "account.move"
2018-02-26 12:17:24 +01:00
loan_line_id = fields.Many2one(
2022-01-10 15:07:49 +01:00
"account.loan.line",
readonly=True,
ondelete="restrict",
2018-02-26 12:17:24 +01:00
)
loan_id = fields.Many2one(
2022-01-10 15:07:49 +01:00
"account.loan",
readonly=True,
store=True,
ondelete="restrict",
2018-02-26 12:17:24 +01:00
)
def action_post(self):
res = super().action_post()
2018-02-26 12:17:24 +01:00
for record in self:
loan_line_id = record.loan_line_id
if loan_line_id:
record.loan_id = loan_line_id.loan_id
2023-09-15 10:04:47 +02:00
record.loan_line_id._check_move_amount()
record.loan_line_id.loan_id._compute_posted_lines()
2018-02-26 12:17:24 +01:00
if record.loan_line_id.sequence == record.loan_id.periods:
record.loan_id.close()
return res