[MIG] account_loan: Migration to 14.0

[UPD] Update account_loan.pot

[UPD] README.rst
This commit is contained in:
aromera
2022-01-10 15:07:49 +01:00
committed by Víctor Martínez
parent f76126a375
commit a07fa9381b
13 changed files with 125 additions and 76 deletions

View File

@@ -14,13 +14,13 @@ Account Loan management
: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/13.0/account_loan
:target: https://github.com/OCA/account-financial-tools/tree/14.0/account_loan
: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-13-0/account-financial-tools-13-0-account_loan
:target: https://translation.odoo-community.org/projects/account-financial-tools-14-0/account-financial-tools-14-0-account_loan
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/92/13.0
:target: https://runbot.odoo-community.org/runbot/92/14.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -71,7 +71,7 @@ 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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_loan%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_loan%0Aversion:%2014.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.
@@ -103,6 +103,6 @@ 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.
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/13.0/account_loan>`_ project on GitHub.
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/14.0/account_loan>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Account Loan management",
"version": "13.0.1.1.0",
"version": "14.0.1.0.0",
"author": "Creu Blanca,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-financial-tools",
"license": "AGPL-3",

View File

@@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -64,6 +64,11 @@ msgstr ""
msgid "Activity State"
msgstr ""
#. module: account_loan
#: model:ir.model.fields,field_description:account_loan.field_account_loan__activity_type_icon
msgid "Activity Type Icon"
msgstr ""
#. module: account_loan
#: code:addons/account_loan/wizard/account_loan_pay_amount.py:0
#, python-format
@@ -208,6 +213,7 @@ msgstr ""
#: model:ir.model.fields,field_description:account_loan.field_account_loan_line__display_name
#: model:ir.model.fields,field_description:account_loan.field_account_loan_pay_amount__display_name
#: model:ir.model.fields,field_description:account_loan.field_account_loan_post__display_name
#: model:ir.model.fields,field_description:account_loan.field_account_move__display_name
msgid "Display Name"
msgstr ""
@@ -271,6 +277,11 @@ msgstr ""
msgid "Followers (Partners)"
msgstr ""
#. module: account_loan
#: model:ir.model.fields,help:account_loan.field_account_loan__activity_type_icon
msgid "Font awesome icon e.g. fa-tasks"
msgstr ""
#. module: account_loan
#: model:ir.ui.menu,name:account_loan.account_loan_generate_wizard_menu
msgid "Generate Loan Entries"
@@ -298,6 +309,7 @@ msgstr ""
#: model:ir.model.fields,field_description:account_loan.field_account_loan_line__id
#: model:ir.model.fields,field_description:account_loan.field_account_loan_pay_amount__id
#: model:ir.model.fields,field_description:account_loan.field_account_loan_post__id
#: model:ir.model.fields,field_description:account_loan.field_account_move__id
msgid "ID"
msgstr ""
@@ -372,7 +384,7 @@ msgstr ""
#. module: account_loan
#: model:ir.model,name:account_loan.model_account_move
msgid "Journal Entries"
msgid "Journal Entry"
msgstr ""
#. module: account_loan
@@ -386,6 +398,7 @@ msgstr ""
#: model:ir.model.fields,field_description:account_loan.field_account_loan_line____last_update
#: model:ir.model.fields,field_description:account_loan.field_account_loan_pay_amount____last_update
#: model:ir.model.fields,field_description:account_loan.field_account_loan_post____last_update
#: model:ir.model.fields,field_description:account_loan.field_account_move____last_update
msgid "Last Modified on"
msgstr ""
@@ -434,10 +447,12 @@ msgstr ""
#. module: account_loan
#: model:ir.model,name:account_loan.model_account_loan
#: model:ir.model.fields,field_description:account_loan.field_account_bank_statement_line__loan_id
#: model:ir.model.fields,field_description:account_loan.field_account_loan_line__loan_id
#: model:ir.model.fields,field_description:account_loan.field_account_loan_pay_amount__loan_id
#: model:ir.model.fields,field_description:account_loan.field_account_loan_post__loan_id
#: model:ir.model.fields,field_description:account_loan.field_account_move__loan_id
#: model:ir.model.fields,field_description:account_loan.field_account_payment__loan_id
#: model_terms:ir.ui.view,arch_db:account_loan.account_loan_form
msgid "Loan"
msgstr ""
@@ -448,7 +463,9 @@ msgid "Loan Amount"
msgstr ""
#. module: account_loan
#: model:ir.model.fields,field_description:account_loan.field_account_bank_statement_line__loan_line_id
#: model:ir.model.fields,field_description:account_loan.field_account_move__loan_line_id
#: model:ir.model.fields,field_description:account_loan.field_account_payment__loan_line_id
msgid "Loan Line"
msgstr ""
@@ -550,6 +567,11 @@ msgstr ""
msgid "Moves"
msgstr ""
#. module: account_loan
#: model:ir.model.fields,field_description:account_loan.field_account_loan__my_activity_date_deadline
msgid "My Activity Deadline"
msgstr ""
#. module: account_loan
#: model:ir.model.fields,field_description:account_loan.field_account_loan__name
#: model:ir.model.fields,field_description:account_loan.field_account_loan_line__name

View File

@@ -1,16 +0,0 @@
# Copyright 2021 Creu Blanca - Alba Riera
from openupgradelib import openupgrade
@openupgrade.migrate()
def migrate(env, version):
openupgrade.logged_query(
env.cr,
"""
UPDATE account_move am
SET loan_line_id = ai.loan_line_id,
loan_id = ai.loan_id
FROM account_invoice ai
WHERE ai.id = am.old_invoice_id and ai.loan_id is not null""",
)

View File

@@ -22,10 +22,7 @@ class AccountLoan(models.Model):
_inherit = ["mail.thread", "mail.activity.mixin"]
def _default_company(self):
force_company = self._context.get("force_company")
if not force_company:
return self.env.user.company_id.id
return force_company
return self.env.company
name = fields.Char(
copy=False,
@@ -61,7 +58,10 @@ class AccountLoan(models.Model):
default="draft",
)
line_ids = fields.One2many(
"account.loan.line", readonly=True, inverse_name="loan_id", copy=False,
"account.loan.line",
readonly=True,
inverse_name="loan_id",
copy=False,
)
periods = fields.Integer(
required=True,
@@ -88,7 +88,7 @@ class AccountLoan(models.Model):
default=0.0,
digits=(8, 6),
help="Currently applied rate",
track_visibility="always",
tracking=True,
)
rate_period = fields.Float(
compute="_compute_rate_period",
@@ -117,12 +117,20 @@ class AccountLoan(models.Model):
default="fixed-annuity",
)
fixed_amount = fields.Monetary(
currency_field="currency_id", compute="_compute_fixed_amount",
currency_field="currency_id",
compute="_compute_fixed_amount",
)
fixed_loan_amount = fields.Monetary(
currency_field="currency_id", readonly=True, copy=False, default=0,
currency_field="currency_id",
readonly=True,
copy=False,
default=0,
)
fixed_periods = fields.Integer(
readonly=True,
copy=False,
default=0,
)
fixed_periods = fields.Integer(readonly=True, copy=False, default=0,)
loan_amount = fields.Monetary(
currency_field="currency_id",
required=True,
@@ -153,7 +161,9 @@ class AccountLoan(models.Model):
help="When checked, the first payment will be on start date",
)
currency_id = fields.Many2one(
"res.currency", compute="_compute_currency", readonly=True,
"res.currency",
compute="_compute_currency",
readonly=True,
)
journal_type = fields.Char(compute="_compute_journal_type")
journal_id = fields.Many2one(
@@ -190,7 +200,9 @@ class AccountLoan(models.Model):
states={"draft": [("readonly", False)]},
)
is_leasing = fields.Boolean(
default=False, readonly=True, states={"draft": [("readonly", False)]},
default=False,
readonly=True,
states={"draft": [("readonly", False)]},
)
leased_asset_account_id = fields.Many2one(
"account.account",
@@ -212,7 +224,8 @@ class AccountLoan(models.Model):
)
move_ids = fields.One2many("account.move", copy=False, inverse_name="loan_id")
pending_principal_amount = fields.Monetary(
currency_field="currency_id", compute="_compute_total_amounts",
currency_field="currency_id",
compute="_compute_total_amounts",
)
payment_amount = fields.Monetary(
currency_field="currency_id",
@@ -438,7 +451,7 @@ class AccountLoan(models.Model):
self.ensure_one()
action = self.env.ref("account.action_move_out_invoice_type")
result = action.read()[0]
result["domain"] = [("loan_id", "=", self.id), ("type", "=", "in_invoice")]
result["domain"] = [("loan_id", "=", self.id), ("move_type", "=", "in_invoice")]
return result
@api.model

View File

@@ -20,38 +20,44 @@ class AccountLoanLine(models.Model):
name = fields.Char(compute="_compute_name")
loan_id = fields.Many2one(
"account.loan", required=True, readonly=True, ondelete="cascade",
"account.loan",
required=True,
readonly=True,
ondelete="cascade",
)
is_leasing = fields.Boolean(
related="loan_id.is_leasing",
readonly=True,
)
is_leasing = fields.Boolean(related="loan_id.is_leasing", readonly=True,)
loan_type = fields.Selection(
[
("fixed-annuity", "Fixed Annuity"),
("fixed-principal", "Fixed Principal"),
("interest", "Only interest"),
],
related="loan_id.loan_type",
readonly=True,
)
loan_state = fields.Selection(
[
("draft", "Draft"),
("posted", "Posted"),
("cancelled", "Cancelled"),
("closed", "Closed"),
],
related="loan_id.state",
readonly=True,
store=True,
)
sequence = fields.Integer(required=True, readonly=True)
date = fields.Date(
required=True, readonly=True, help="Date when the payment will be accounted",
required=True,
readonly=True,
help="Date when the payment will be accounted",
)
long_term_loan_account_id = fields.Many2one(
"account.account", readony=True, related="loan_id.long_term_loan_account_id",
"account.account",
readonly=True,
related="loan_id.long_term_loan_account_id",
)
currency_id = fields.Many2one(
"res.currency",
related="loan_id.currency_id",
)
rate = fields.Float(
required=True,
readonly=True,
digits=(8, 6),
)
currency_id = fields.Many2one("res.currency", related="loan_id.currency_id",)
rate = fields.Float(required=True, readonly=True, digits=(8, 6),)
pending_principal_amount = fields.Monetary(
currency_field="currency_id",
readonly=True,
@@ -88,7 +94,10 @@ class AccountLoanLine(models.Model):
compute="_compute_amounts",
help="Pending amount of the loan after the payment",
)
move_ids = fields.One2many("account.move", inverse_name="loan_line_id",)
move_ids = fields.One2many(
"account.move",
inverse_name="loan_line_id",
)
has_moves = fields.Boolean(compute="_compute_has_moves")
has_invoices = fields.Boolean(compute="_compute_has_invoices")
_sql_constraints = [
@@ -241,9 +250,7 @@ class AccountLoanLine(models.Model):
def move_line_vals(self):
vals = []
partner = self.loan_id.partner_id.with_context(
force_company=self.loan_id.company_id.id
)
partner = self.loan_id.partner_id.with_company(self.loan_id.company_id)
vals.append(
{
"account_id": partner.property_account_payable_id.id,
@@ -287,7 +294,7 @@ class AccountLoanLine(models.Model):
return {
"loan_line_id": self.id,
"loan_id": self.loan_id.id,
"type": "in_invoice",
"move_type": "in_invoice",
"partner_id": self.loan_id.partner_id.id,
"invoice_date": self.date,
"journal_id": self.loan_id.journal_id.id,
@@ -426,7 +433,10 @@ class AccountLoanLine(models.Model):
"default_loan_line_id": self.id,
"default_loan_id": self.loan_id.id,
}
result["domain"] = [("loan_line_id", "=", self.id), ("type", "=", "in_invoice")]
result["domain"] = [
("loan_line_id", "=", self.id),
("move_type", "=", "in_invoice"),
]
if len(self.move_ids) == 1:
res = self.env.ref("account.view_move_form", False)
result["views"] = [(res and res.id or False, "form")]

View File

@@ -8,10 +8,15 @@ class AccountMove(models.Model):
_inherit = "account.move"
loan_line_id = fields.Many2one(
"account.loan.line", readonly=True, ondelete="restrict",
"account.loan.line",
readonly=True,
ondelete="restrict",
)
loan_id = fields.Many2one(
"account.loan", readonly=True, store=True, ondelete="restrict",
"account.loan",
readonly=True,
store=True,
ondelete="restrict",
)
def post(self):

View File

@@ -3,3 +3,6 @@ access_account_loan,account.loan,model_account_loan,account.group_account_user,1
access_account_loan_manager,account.loan,model_account_loan,account.group_account_manager,1,1,1,1
access_account_loan_line,account.loan.line,model_account_loan_line,account.group_account_user,1,0,0,0
access_account_loan_line_manager,account.loan.line,model_account_loan_line,account.group_account_manager,1,1,1,1
access_account_loan_generate_wizard,access_account_loan_generate_wizard,model_account_loan_generate_wizard,account.group_account_user,1,0,0,0
access_account_loan_pay_amount,access_account_loan_pay_amount,model_account_loan_pay_amount,account.group_account_user,1,0,0,0
access_account_loan_post,access_account_loan_post,model_account_loan_post,account.group_account_user,1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
3 access_account_loan_manager account.loan model_account_loan account.group_account_manager 1 1 1 1
4 access_account_loan_line account.loan.line model_account_loan_line account.group_account_user 1 0 0 0
5 access_account_loan_line_manager account.loan.line model_account_loan_line account.group_account_manager 1 1 1 1
6 access_account_loan_generate_wizard access_account_loan_generate_wizard model_account_loan_generate_wizard account.group_account_user 1 0 0 0
7 access_account_loan_pay_amount access_account_loan_pay_amount model_account_loan_pay_amount account.group_account_user 1 0 0 0
8 access_account_loan_post access_account_loan_post model_account_loan_post account.group_account_user 1 0 0 0

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/13.0/account_loan"><img alt="OCA/account-financial-tools" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-financial-tools-13-0/account-financial-tools-13-0-account_loan"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/92/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/14.0/account_loan"><img alt="OCA/account-financial-tools" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-financial-tools-14-0/account-financial-tools-14-0-account_loan"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/92/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module extends the functionality of accounting to support loans.
It will create automatically moves or invoices for loans.
Moreover, you can check the pending amount to be paid and reduce the debt.</p>
@@ -420,7 +420,7 @@ leases before a selected date</li>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-tools/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_loan%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_loan%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@@ -446,7 +446,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/13.0/account_loan">OCA/account-financial-tools</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/14.0/account_loan">OCA/account-financial-tools</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@@ -215,7 +215,10 @@
</form>
</field>
</record>
<act_window id="account_loan_action" name="Loans" res_model="account.loan" />
<record id="account_loan_action" model="ir.actions.act_window">
<field name="name">Loans</field>
<field name="res_model">account.loan</field>
</record>
<menuitem
id="account_loan_menu"
parent="account.menu_finance_entries"

View File

@@ -8,7 +8,7 @@
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form" />
<field name="arch" type="xml">
<field name="company_id" position="after">
<field name="date" position="after">
<field
name="loan_line_id"
attrs="{'invisible': [('loan_line_id', '=', False)]}"

View File

@@ -9,14 +9,21 @@ class AccountLoan(models.TransientModel):
_name = "account.loan.pay.amount"
_description = "Loan pay amount"
loan_id = fields.Many2one("account.loan", required=True, readonly=True,)
loan_id = fields.Many2one(
"account.loan",
required=True,
readonly=True,
)
currency_id = fields.Many2one(
"res.currency", related="loan_id.currency_id", readonly=True
)
cancel_loan = fields.Boolean(default=False,)
cancel_loan = fields.Boolean(
default=False,
)
date = fields.Date(required=True, default=fields.Date.today())
amount = fields.Monetary(
currency_field="currency_id", string="Amount to reduce from Principal",
currency_field="currency_id",
string="Amount to reduce from Principal",
)
fees = fields.Monetary(currency_field="currency_id", string="Bank fees")

View File

@@ -22,11 +22,15 @@ class AccountLoanPost(models.TransientModel):
if loan.is_leasing:
return loan.leased_asset_account_id.id
else:
return loan.partner_id.with_context(
force_company=loan.company_id.id
return loan.partner_id.with_company(
loan.company_id
).property_account_receivable_id.id
loan_id = fields.Many2one("account.loan", required=True, readonly=True,)
loan_id = fields.Many2one(
"account.loan",
required=True,
readonly=True,
)
journal_id = fields.Many2one(
"account.journal", required=True, default=lambda r: r._default_journal_id()
)
@@ -36,9 +40,7 @@ class AccountLoanPost(models.TransientModel):
def move_line_vals(self):
res = list()
partner = self.loan_id.partner_id.with_context(
force_company=self.loan_id.company_id.id
)
partner = self.loan_id.partner_id.with_company(self.loan_id.company_id)
line = self.loan_id.line_ids.filtered(lambda r: r.sequence == 1)
res.append(
{