e56f6f9e26
Co-authored-by: Enric Tobella <etobella@creublanca.es>
30 lines
980 B
Python
30 lines
980 B
Python
# Copyright 2018 Creu Blanca
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|
|
|
from odoo import fields, models
|
|
|
|
|
|
class AccountMove(models.Model):
|
|
_inherit = "account.move"
|
|
|
|
loan_line_id = fields.Many2one(
|
|
"account.loan.line", readonly=True, ondelete="restrict",
|
|
)
|
|
loan_id = fields.Many2one(
|
|
"account.loan", readonly=True, store=True, ondelete="restrict",
|
|
)
|
|
|
|
def post(self):
|
|
res = super().post()
|
|
for record in self:
|
|
loan_line_id = record.loan_line_id
|
|
if loan_line_id:
|
|
if not record.loan_line_id:
|
|
record.loan_line_id = loan_line_id
|
|
record.loan_id = loan_line_id.loan_id
|
|
record.loan_line_id.check_move_amount()
|
|
record.loan_line_id.loan_id.compute_posted_lines()
|
|
if record.loan_line_id.sequence == record.loan_id.periods:
|
|
record.loan_id.close()
|
|
return res
|