Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
c7a1f49
[ADD] account_loan
etobella Feb 26, 2018
d2b13e8
[11.0][account_loan] Change logger level on import dependency
jcoux Jul 2, 2018
540077b
[IMP] Account_loan: Add the option to automatically post invoices
etobella Jul 18, 2018
c97459a
Add Loan Type info in README
rafaelbn Oct 11, 2018
bcb3230
Translated using Weblate (German)
rschnapka Oct 10, 2018
e4987e5
[11.0][FIX] ValueError: min() arg is an empty sequence
Jan 8, 2019
eb06283
[MIG] account_loan: Migration to 12.0
amcor May 27, 2019
12a0bf3
[IMP] account_loan: Fix rounding issues
etobella May 22, 2019
00265c1
[IMP] account_loan: Add fixed-annuity-begin
etobella Jun 26, 2019
40ecf26
[FIX] test error on multi action_move_create
amcor Apr 14, 2020
37ca3f2
Translated using Weblate (German)
marylla Apr 27, 2020
e44c9bf
Translated using Weblate (German)
marylla May 6, 2020
807dc40
Translated using Weblate (Spanish)
etobella May 18, 2020
2086e1c
Translated using Weblate (Portuguese)
alvarorib May 20, 2020
41faa89
Translated using Weblate (German)
marylla Jun 12, 2020
c1b00ae
Translated using Weblate (Portuguese (Brazil))
mliell Jun 13, 2020
8b2255c
Translated using Weblate (Slovenian)
sysadminmatmoz Aug 11, 2020
02d3e8d
Translated using Weblate (Portuguese (Brazil))
marcelsavegnago Jan 14, 2021
f975301
[IMP] account_loan: black,isort,prettier
albariera Feb 23, 2021
9c629de
[MIG] account_loan: Migration to 13.0
albariera Feb 23, 2021
e251a54
[IMP] *: pre-commit execution
joao-p-marques Nov 25, 2021
1cce54a
[MIG] account_loan: Migration to 14.0
Jan 10, 2022
dc34fcf
[FIX] account_loan: missing acl line
cubells Feb 3, 2022
ce2a404
[FIX] account_loan: post() -> action_post()
MiquelRForgeFlow Feb 11, 2022
894fb61
Translated using Weblate (Italian)
francesco-ooops Apr 12, 2022
c09af75
Translated using Weblate (Italian)
SicurSam May 10, 2022
92fcfde
Translated using Weblate (Portuguese (Brazil))
douglascstd Dec 9, 2022
c372975
Translated using Weblate (Italian)
mymage Dec 28, 2022
3852b06
Translated using Weblate (Italian)
francesco-ooops Dec 30, 2022
0eceffa
[14.0][FIX] account_loan, account_loan_line & account_loan_generate_e…
sanchonuria Feb 7, 2023
42a9dd7
[FIX] account_loan
etobella Mar 1, 2023
5edd3e2
[IMP] account_loan: fields added to account list view
Bearnard21 Mar 2, 2023
06d17c3
[14.0][IMP] account_loan: remove numpy from explicit requirements
HekkiMelody Mar 2, 2023
65d4a61
Translated using Weblate (Italian)
mymage Mar 30, 2023
9524039
Translated using Weblate (Slovenian)
sysadminmatmoz Mar 31, 2023
aefbe55
Translated using Weblate (Italian)
mymage Apr 3, 2023
76ef581
Translated using Weblate (Italian)
francesco-ooops Apr 7, 2023
fa0a33b
Translated using Weblate (Italian)
mymage Apr 12, 2023
e2253da
Translated using Weblate (Italian)
francesco-ooops Apr 20, 2023
3b03211
Translated using Weblate (Italian)
mymage Aug 22, 2023
511ef1f
[MIG] account_loan: Mirgation to 16.0
etobella Sep 15, 2023
f674042
[IMP] account_loan: Show lended loans from partner
etobella Sep 15, 2023
b777a42
[IMP] account_loan: Allow to increase the amount of the loan
etobella Sep 15, 2023
b856467
[IMP]Add some optional fields to loan tree view
matteonext Sep 25, 2023
e4de912
[IMP] account_loan: add loan lines menu item
matteonext Sep 29, 2023
5fdfd1e
Translated using Weblate (Spanish)
Ivorra78 Oct 9, 2023
1e37579
[FIX] account_loan: Use the proper tree on the loan view
etobella Oct 17, 2023
639c775
[FIX] account_loan: use company_ids in ir.rule multi-company
AnizR Oct 31, 2023
2b92ba3
Translated using Weblate (Spanish (Argentina))
ibuioli Nov 12, 2023
94cf8e8
Translated using Weblate (Catalan)
BrunoBailo Feb 1, 2024
6100dba
[IMP] account_loan: add multi-company ir_rule for 'account_loan_line'
AnizR Feb 8, 2024
0f33b4b
Translated using Weblate (Swedish)
jakobkrabbe Feb 27, 2024
ffbd84e
Translated using Weblate (Italian)
mymage Mar 20, 2024
61b8f9a
Translated using Weblate (French)
pfteyy Mar 28, 2024
30d37c5
Translated using Weblate (Italian)
mymage Aug 1, 2024
a6fdd5b
Translated using Weblate (Portuguese (Brazil))
SottomaiorMacedoTec Aug 6, 2024
beddb7d
Translated using Weblate (Italian)
mymage Aug 19, 2024
1ec6645
Translated using Weblate (Portuguese (Brazil))
SottomaiorMacedoTec Sep 3, 2024
a9347a9
[FIX] account_loan: Set name on line in order to make it compatible w…
etobella Oct 15, 2024
ca598c4
[IMP] account_loan: pre-commit auto fixes
victoralmau Oct 30, 2024
6cb9b0f
[MIG] account_loan: Migration to 17.0
JT-Odoo Aug 15, 2024
142878e
[MIG] account_loan: Finish migration to 17.0
victoralmau Oct 30, 2024
0636f72
[OU-FIX] account_loan: use env in openupgrade load_data instead of cr
victoralmau Nov 11, 2024
2c6c6fc
[FIX] account_loan: Add freeze_time to tests to avoid errors on some …
victoralmau Jan 29, 2025
6608245
[IMP] account_loan: Edit table in draft
juancarlosonate-tecnativa Apr 15, 2025
7825838
[FIX] account_loan: Always set the correct date to avoid incorrect va…
victoralmau Apr 24, 2025
f9bf605
[FIX] account_loan: Define the correct date of the lines if payment_o…
victoralmau Apr 25, 2025
42f6234
Translated using Weblate (Italian)
mymage Apr 28, 2025
0af5f17
[IMP] account_loan: Add class="oe_highlight" to Post button
victoralmau Apr 30, 2025
7426a10
[IMP] account_loan: Add Reset to draft button
victoralmau Apr 30, 2025
f0423d8
Translated using Weblate (Italian)
mymage May 10, 2025
3a96711
[IMP] account_loan: Editable table draft, or in posted if no moves ex…
juancarlosonate-tecnativa Jun 10, 2025
d586ba2
Translated using Weblate (Italian)
mymage Jun 11, 2025
49fab77
[IMP] account_loan: add pending_principal_amount total to list view
Chionne27 Mar 26, 2025
eb895b8
[IMP] account_loan: add pivot view
Chionne27 Mar 28, 2025
5b3aa90
[IMP] account_loan: Be loan donor (allow negative amounts)
pedrobaeza Nov 3, 2025
68dd372
[IMP] account_loan: pre-commit auto fixes
BhaveshHeliconia Jun 20, 2025
dd1ef22
[MIG] account_loan: Migration to 18.0
BhaveshHeliconia Jun 20, 2025
ec9195f
Translated using Weblate (Italian)
mymage Dec 15, 2025
5dccf1a
[IMP] account_loan: pre-commit auto fixes
petrus-v Feb 6, 2026
1650698
[MIG] account_loan: Migration to 19.0
petrus-v Feb 6, 2026
ffb3832
[IMP] Refactore to add hooks in order to add infos in vals
lmarion-source Nov 20, 2024
7d7d12d
[FIX] account_loan: Make long term in a better way
etobella Jun 19, 2025
6cc6090
[IMP] account_loan: add inheritance hook to condition posting of moves
AnizR Dec 2, 2024
eb63b4d
[IMP] account_loan: Allow to modify currency_id on account loan
lmarion-source Sep 3, 2025
7708a17
[IMP] account_loan: Currency not readonly + convert in company currency
lmarion-source Sep 11, 2025
45cecf0
oca-port: blacklist PR(s) , 1721, 1737, 1750, 1760, 1816, 1952 for ac…
petrus-v Feb 11, 2026
41c070d
[MIG] account_loan: forwarded PRs migration
petrus-v Feb 11, 2026
8fa4495
[FIX] account_loan: take care of residual_amount while checking consi…
petrus-v Feb 19, 2026
1246bc8
[REF] account_loan: rename loan_type into loan_method
petrus-v Feb 19, 2026
7deec92
[REF] account_loan,account_leasing: add loan_type loan/borrow/leasing
petrus-v Feb 20, 2026
789e159
[REF] account_loan: stop compute laon_type
petrus-v Feb 25, 2026
99ce290
[REF] account_leasing: remove compute loan_type support
petrus-v Feb 25, 2026
090a655
[REF] account_loan,account_leasing: more flexibility to overwrite in …
petrus-v Feb 25, 2026
9e34d76
[FIX] account_loan: use currency compare_amounts instead of float com…
petrus-v Feb 25, 2026
4b3d843
[FIX] account_loan: fix test canceling laon
petrus-v Feb 25, 2026
8e63756
[FIX] account_loan,account_leasing: really store journal on account_loan
petrus-v Feb 25, 2026
d56a1b1
[REF] account_loan: support post entries at date
petrus-v Mar 5, 2026
e3a9879
[FIX] account_loan: use commercial_partner_id on loan account line
petrus-v Mar 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .oca/oca-port/blacklist/account_loan.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"pull_requests": {
"orphaned_commits": "(auto) Nothing to port from PR #",
"OCA/account-financial-tools#1721": "migration source pr",
"OCA/account-financial-tools#1737": "Already ported",
"OCA/account-financial-tools#1750": "Already ported",
"OCA/account-financial-tools#1760": "Already ported",
"OCA/account-financial-tools#1816": "Already ported",
"OCA/account-financial-tools#1952": "Already ported"
}
}
129 changes: 129 additions & 0 deletions account_leasing/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

===============
Account Leasing
===============

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:414c44c1e523a88ee09257d5ca6197adf3a43a59b760053499549b0324216697
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github
:target: https://github.com/OCA/account-financial-tools/tree/19.0/account_leasing
:alt: OCA/account-financial-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-financial-tools-19-0/account-financial-tools-19-0-account_leasing
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=19.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends the functionality of account loans to manage
leasing. It will create automatically moves or invoices for loans.
Moreover, you can check the pending amount to be paid and reduce the
debt.

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module, you need to:

1. Go to Invoicing / Accounting > Accounting > Loans
2. Configure a leasing selecting the company, loan type, amount, rate
and accounts
3. Post the loan, it will automatically create an account move with the
expected amounts
4. Create automatically the account moves / invoices related to leases
before a selected date

On a posted lease you can:

- Create moves or invoices (according to the configuration)
- Modify rates when needed (only unposted lines will be modified)
- Reduce or cancel the debt of a lease

|Try me on Runbot|

.. |Try me on Runbot| image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:target: https://runbot.odoo-community.org/runbot/92/12.0

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-tools/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_leasing%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Pierre Verkest

Contributors
------------

- Enric Tobella <etobella@creublanca.es>
- Bhavesh Odedra <bodedra@opensourceintegrators.com>
- Alberto Martín Cortada <alberto.martin@guadaltech.es>
- `Tecnativa <https://www.tecnativa.com>`__:

- Juan Carlos Oñate

- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__

- Bhavesh Heliconia

- Pierre Verkest <pierre@verkest.fr>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-etobella| image:: https://github.com/etobella.png?size=40px
:target: https://github.com/etobella
:alt: etobella
.. |maintainer-petrus-v| image:: https://github.com/petrus-v.png?size=40px
:target: https://github.com/petrus-v
:alt: petrus-v

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-etobella| |maintainer-petrus-v|

This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/19.0/account_leasing>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions account_leasing/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models
from . import wizards
20 changes: 20 additions & 0 deletions account_leasing/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2026 ACSONE SA/NV (<http://acsone.eu>)
# @author Pierre Verkest <pierre@verkest.fr>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Account Leasing",
"version": "19.0.1.0.0",
"author": "Pierre Verkest, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-financial-tools",
"license": "AGPL-3",
"category": "Accounting",
"depends": ["account", "account_loan"],
"data": [
"views/account_loan_lines_view.xml",
"views/account_loan_view.xml",
"wizards/account_loan_generate_entries_view.xml",
],
"installable": True,
"maintainers": ["etobella", "petrus-v"],
"external_dependencies": {},
}
5 changes: 5 additions & 0 deletions account_leasing/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2018 Creu Blanca
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import account_loan
from . import account_loan_line
81 changes: 81 additions & 0 deletions account_leasing/models/account_loan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Copyright 2018 Creu Blanca
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
from odoo.exceptions import ValidationError
from odoo.fields import Domain


class AccountLoan(models.Model):
_inherit = "account.loan"

loan_type = fields.Selection(
selection_add=[("leasing", "Leasing")],
ondelete={"leasing": "set default"},
)
leased_asset_account_id = fields.Many2one(
"account.account",
domain="[('company_ids', '=', company_id)]",
)
long_term_journal_id = fields.Many2one(
"account.journal",
domain="[('company_id', '=', company_id),('type', '=', 'general')]",
readonly=True,
check_company=True,
)
product_id = fields.Many2one(
"product.product",
string="Loan product",
help="Product where the amount of the loan will be assigned when the "
"invoice is created",
)
interests_product_id = fields.Many2one(
"product.product",
string="Interest product",
help="Product where the amount of interests will be assigned when the "
"invoice is created",
)
post_invoice = fields.Boolean(
default=True, help="Invoices will be posted automatically"
)

def _check_laon_type_constrains(self):
res = super()._check_laon_type_constrains()
if self.loan_type == "leasing" and self.loan_amount < 0:
raise ValidationError(
self.env._("Leasing type must have postive amount or change the type")
)
return res

def _journal_type_domain(self):
if self.loan_type == "leasing":
return Domain("type", "=", "purchase")
return super()._journal_type_domain()

@api.onchange("loan_type", "company_id")
def _onchange_loan_type(self):
self.residual_amount = 0.0

def view_account_invoices(self):
self.ensure_one()
result = self.env["ir.actions.act_window"]._for_xml_id(
"account.action_move_in_invoice_type"
)
result["domain"] = Domain(
[("loan_id", "=", self.id), ("move_type", "=", "in_invoice")]
)
return result

@api.model
def _generate_leasing_entries(self, date):
res = []
for record in self.search(
Domain([("state", "=", "posted"), ("loan_type", "=", "leasing")])
):
res += record.line_ids.filtered(
lambda r: r.date <= date and not r.move_ids
)._generate_invoice()
return res

@api.model
def _loan_and_borrow_domain(self):
return Domain("loan_type", "!=", "leasing")
134 changes: 134 additions & 0 deletions account_leasing/models/account_loan_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Copyright 2018 Creu Blanca
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import Command, fields, models
from odoo.exceptions import UserError
from odoo.fields import Domain


class AccountLoanLine(models.Model):
_inherit = "account.loan.line"

loan_type = fields.Selection(
related="loan_id.loan_type",
)

def _invoice_vals(self):
self.ensure_one()
return {
"loan_line_id": self.id,
"loan_id": self.loan_id.id,
"move_type": "in_invoice",
"partner_id": self.loan_id.partner_id.id,
"invoice_date": self.date,
"journal_id": self.loan_id.journal_id.id,
"company_id": self.loan_id.company_id.id,
"invoice_line_ids": [
Command.create(vals) for vals in self._invoice_line_vals()
],
}

def _add_basic_values_invoice_line(self, vals):
vals.append(
{
"product_id": self.loan_id.product_id.id,
"name": self.loan_id.product_id.name,
"quantity": 1,
"price_unit": self.principal_amount,
"account_id": self.loan_id.short_term_loan_account_id.id,
}
)
return vals

def _add_interests_values_invoice_line(self, vals):
vals.append(
{
"product_id": self.loan_id.interests_product_id.id,
"name": self.loan_id.interests_product_id.name,
"quantity": 1,
"price_unit": self.interests_amount,
"account_id": self.loan_id.interest_expenses_account_id.id,
}
)
return vals

def _invoice_line_vals(self):
vals = list()
vals = self._add_basic_values_invoice_line(vals)
vals = self._add_interests_values_invoice_line(vals)
return vals

def _generate_invoice(self):
"""
Computes invoices of leases
:return: list of account.move generated
"""
res = []
for record in self:
if not record.move_ids:
if record.loan_id.line_ids.filtered(
lambda r, rec=record: r.date < rec.date and not r.move_ids
):
raise UserError(self.env._("Some invoices must be created first"))
invoice = self.env["account.move"].create(record._invoice_vals())
res.append(invoice.id)
for line in invoice.invoice_line_ids:
line.tax_ids = line._get_computed_taxes()
invoice.flush_recordset()
invoice.filtered(
lambda m: m.currency_id.round(m.amount_total) < 0
).action_switch_move_type()
if record.loan_id.post_invoice:
invoice.action_post()
if (
record.long_term_loan_account_id
and record.long_term_principal_amount != 0
):
move = self.env["account.move"].create(
record._long_term_move_vals()
)
if record.loan_id.post_invoice:
move.action_post()
res.append(move.id)
return res

def _long_term_move_vals(self):
return {
"loan_line_id": self.id,
"loan_id": self.loan_id.id,
"date": self.date,
"ref": self.name,
"journal_id": self.loan_id.long_term_journal_id.id
or self.loan_id.journal_id.id,
"line_ids": [
Command.create(vals) for vals in self._get_long_term_move_line_vals()
],
}

def view_account_values(self):
"""Shows the invoice if it is a leasing or the move if it is a loan"""
self.ensure_one()
if self.loan_type == "leasing":
return self.view_account_invoices()
return super().view_account_values()

def _generate_account_entry(self):
self.ensure_one()
if self.loan_type == "leasing":
return self._generate_invoice()
return super()._generate_account_entry()

def view_account_invoices(self):
self.ensure_one()
result = self.env["ir.actions.act_window"]._for_xml_id(
"account.action_move_out_invoice_type"
)
result["context"] = {
"default_loan_line_id": self.id,
"default_loan_id": self.loan_id.id,
}
result["domain"] = Domain("loan_line_id", "=", self.id)
if len(self.move_ids) == 1:
res = self.env.ref("account.view_move_form", False)
result["views"] = [(res and res.id or False, "form")]
result["res_id"] = self.move_ids.id
return result
3 changes: 3 additions & 0 deletions account_leasing/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
Loading