Skip to content

Commit

Permalink
This is a combination of 2 commits.
Browse files Browse the repository at this point in the history
[IMP] account_financial_risk: pre-commit auto fixes

[MIG] account_financial_risk: Migration to 17.0

Refactor code for financial risk handling

Update tax_group_taxes variable and add help text to invoice_unpaid_margin and allow_overrisk_invoice_validation settings

[FIX] pre-commit

[MIG] account_financial_risk: Migration to 17.0

[MIG] account_financial_risk: Migration to 17.0

[MIG] account_financial_risk: Migration to 17.0
  • Loading branch information
Mat-moran authored and sbiosca-s73 committed May 22, 2024
1 parent fb0f7a0 commit 6d95af6
Show file tree
Hide file tree
Showing 17 changed files with 149 additions and 155 deletions.
78 changes: 40 additions & 38 deletions account_financial_risk/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,30 @@ Account Financial Risk
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcredit--control-lightgray.png?logo=github
:target: https://github.com/OCA/credit-control/tree/16.0/account_financial_risk
:target: https://github.com/OCA/credit-control/tree/17.0/account_financial_risk
:alt: OCA/credit-control
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/credit-control-16-0/credit-control-16-0-account_financial_risk
:target: https://translation.odoo-community.org/projects/credit-control-17-0/credit-control-17-0-account_financial_risk
: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/credit-control&target_branch=16.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/credit-control&target_branch=17.0
:alt: Try me on Runboat

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

Adds a new page in partner to manage its *Financial Risk*.
(Only visible for User or Manager Financial Risk groups)
Adds a new page in partner to manage its *Financial Risk*. (Only visible
for User or Manager Financial Risk groups)

If any limit is exceeded, you won't be able to confirm any of its invoices
unless you are authorized (Financial Risk Manager group).
You can click in risk amount to view amount origin.
If any limit is exceeded, you won't be able to confirm any of its
invoices unless you are authorized (Financial Risk Manager group). You
can click in risk amount to view amount origin.

.. figure:: https://raw.githubusercontent.com/OCA/credit-control/16.0/account_financial_risk/static/description/financial_risk_click.png
|image1|

When a non-zero credit limit is set, the last modification date is saved and
displayed next to the credit limit.
When a non-zero credit limit is set, the last modification date is saved
and displayed next to the credit limit.

.. |image1| image:: https://raw.githubusercontent.com/OCA/credit-control/17.0/account_financial_risk/static/description/financial_risk_click.png

**Table of contents**

Expand All @@ -50,63 +52,63 @@ Configuration

To configure this module, you need to:

#. Go to User and set group User or Manager Financial Risk
#. Go to *Invoicing/Accounting > Configuration > Settings > Accounting*
#. In the *Customer Payments* section, fill *Maturity Margin* for setting the
number of days to last after the due date to consider an invoice as unpaid.
1. Go to User and set group User or Manager Financial Risk
2. Go to *Invoicing/Accounting > Configuration > Settings > Accounting*
3. In the *Customer Payments* section, fill *Maturity Margin* for
setting the number of days to last after the due date to consider an
invoice as unpaid.

Usage
=====

To use this module, you need to:

#. Go to *Invoicing/Accounting > Customers > Customers*.
#. Select an existing customer or create a new one.
#. Open the *Financial Risk* tab.
#. Set limits and choose options to compute in credit limit.
#. Go to *Invoicing/Accounting > Customers > Invoices* and create new
1. Go to *Invoicing/Accounting > Customers > Customers*.
2. Select an existing customer or create a new one.
3. Open the *Financial Risk* tab.
4. Set limits and choose options to compute in credit limit.
5. Go to *Invoicing/Accounting > Customers > Invoices* and create new
customer invoices.
#. Test the restriction trying to create an invoice for the partner for an
amount higher of the limit you have set.
#. Return to Customer *Financial Risk* tab and click in amount to view origin.
6. Test the restriction trying to create an invoice for the partner for
an amount higher of the limit you have set.
7. Return to Customer *Financial Risk* tab and click in amount to view
origin.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/credit-control/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/credit-control/issues/new?body=module:%20account_financial_risk%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/credit-control/issues/new?body=module:%20account_financial_risk%0Aversion:%2017.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
~~~~~~~
-------

* Tecnativa

Contributors
~~~~~~~~~~~~

* `Tecnativa <https://www.tecnativa.com>`_:

* Carlos Dauden
* Pedro M. Baeza
* Ernesto Tejeda
------------

* Agathe Mollé <agathe.molle@savoirfairelinux.com>
- `Tecnativa <https://www.tecnativa.com>`__:

* Ugne Sinkeviciene <ugne@versada.eu>
- Carlos Dauden
- Pedro M. Baeza
- Ernesto Tejeda

* `Ooops404 <https://www.ooops404.com>`__:
- Agathe Mollé <agathe.molle@savoirfairelinux.com>
- Ugne Sinkeviciene <ugne@versada.eu>
- `Ooops404 <https://www.ooops404.com>`__:

* Ilyas <irazor147@gmail.com>
- Ilyas <irazor147@gmail.com>

Maintainers
~~~~~~~~~~~
-----------

This module is maintained by the OCA.

Expand All @@ -126,6 +128,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-carlosdauden|

This module is part of the `OCA/credit-control <https://github.com/OCA/credit-control/tree/16.0/account_financial_risk>`_ project on GitHub.
This module is part of the `OCA/credit-control <https://github.com/OCA/credit-control/tree/17.0/account_financial_risk>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion account_financial_risk/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Account Financial Risk",
"summary": "Manage customer risk",
"version": "16.0.1.2.2",
"version": "17.0.1.0.0",
"category": "Accounting",
"license": "AGPL-3",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand Down
1 change: 0 additions & 1 deletion account_financial_risk/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ def _compute_risk_account_amount(self):
group["domain"] + [("partner_id", "in", customers.ids)],
group["fields"],
group["group_by"],
orderby="id",
lazy=False,
)
for partner in customers:
Expand Down
3 changes: 3 additions & 0 deletions account_financial_risk/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
8 changes: 8 additions & 0 deletions account_financial_risk/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
To configure this module, you need to:

1. Go to User and set group User or Manager Financial Risk
2. Go to *Invoicing/Accounting \> Configuration \> Settings \>
Accounting*
3. In the *Customer Payments* section, fill *Maturity Margin* for
setting the number of days to last after the due date to consider an
invoice as unpaid.
6 changes: 0 additions & 6 deletions account_financial_risk/readme/CONFIGURE.rst

This file was deleted.

8 changes: 8 additions & 0 deletions account_financial_risk/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- [Tecnativa](https://www.tecnativa.com):
- Carlos Dauden
- Pedro M. Baeza
- Ernesto Tejeda
- Agathe Mollé \<<agathe.molle@savoirfairelinux.com>\>
- Ugne Sinkeviciene \<<ugne@versada.eu>\>
- [Ooops404](https://www.ooops404.com):
- Ilyas \<<irazor147@gmail.com>\>
13 changes: 0 additions & 13 deletions account_financial_risk/readme/CONTRIBUTORS.rst

This file was deleted.

11 changes: 11 additions & 0 deletions account_financial_risk/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Adds a new page in partner to manage its *Financial Risk*. (Only visible
for User or Manager Financial Risk groups)

If any limit is exceeded, you won't be able to confirm any of its
invoices unless you are authorized (Financial Risk Manager group). You
can click in risk amount to view amount origin.

![](../static/description/financial_risk_click.png)

When a non-zero credit limit is set, the last modification date is saved
and displayed next to the credit limit.
11 changes: 0 additions & 11 deletions account_financial_risk/readme/DESCRIPTION.rst

This file was deleted.

12 changes: 12 additions & 0 deletions account_financial_risk/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
To use this module, you need to:

1. Go to *Invoicing/Accounting \> Customers \> Customers*.
2. Select an existing customer or create a new one.
3. Open the *Financial Risk* tab.
4. Set limits and choose options to compute in credit limit.
5. Go to *Invoicing/Accounting \> Customers \> Invoices* and create new
customer invoices.
6. Test the restriction trying to create an invoice for the partner for
an amount higher of the limit you have set.
7. Return to Customer *Financial Risk* tab and click in amount to view
origin.
11 changes: 0 additions & 11 deletions account_financial_risk/readme/USAGE.rst

This file was deleted.

37 changes: 18 additions & 19 deletions account_financial_risk/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down Expand Up @@ -369,17 +368,15 @@ <h1 class="title">Account Financial Risk</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:e81b96f2a825ac1d5a813a977d901282590efdf6736885168b6da4fd5eebcb86
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" 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 image-reference" 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 image-reference" href="https://github.com/OCA/credit-control/tree/16.0/account_financial_risk"><img alt="OCA/credit-control" src="https://img.shields.io/badge/github-OCA%2Fcredit--control-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/credit-control-16-0/credit-control-16-0-account_financial_risk"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/credit-control&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Adds a new page in partner to manage its <em>Financial Risk</em>.
(Only visible for User or Manager Financial Risk groups)</p>
<p>If any limit is exceeded, you won’t be able to confirm any of its invoices
unless you are authorized (Financial Risk Manager group).
You can click in risk amount to view amount origin.</p>
<div class="figure">
<img alt="https://raw.githubusercontent.com/OCA/credit-control/16.0/account_financial_risk/static/description/financial_risk_click.png" src="https://raw.githubusercontent.com/OCA/credit-control/16.0/account_financial_risk/static/description/financial_risk_click.png" />
</div>
<p>When a non-zero credit limit is set, the last modification date is saved and
displayed next to the credit limit.</p>
<p><a class="reference external image-reference" 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 image-reference" 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 image-reference" href="https://github.com/OCA/credit-control/tree/17.0/account_financial_risk"><img alt="OCA/credit-control" src="https://img.shields.io/badge/github-OCA%2Fcredit--control-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/credit-control-17-0/credit-control-17-0-account_financial_risk"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/credit-control&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Adds a new page in partner to manage its <em>Financial Risk</em>. (Only visible
for User or Manager Financial Risk groups)</p>
<p>If any limit is exceeded, you won’t be able to confirm any of its
invoices unless you are authorized (Financial Risk Manager group). You
can click in risk amount to view amount origin.</p>
<p><img alt="image1" src="https://raw.githubusercontent.com/OCA/credit-control/17.0/account_financial_risk/static/description/financial_risk_click.png" /></p>
<p>When a non-zero credit limit is set, the last modification date is saved
and displayed next to the credit limit.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
Expand All @@ -400,8 +397,9 @@ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<ol class="arabic simple">
<li>Go to User and set group User or Manager Financial Risk</li>
<li>Go to <em>Invoicing/Accounting &gt; Configuration &gt; Settings &gt; Accounting</em></li>
<li>In the <em>Customer Payments</em> section, fill <em>Maturity Margin</em> for setting the
number of days to last after the due date to consider an invoice as unpaid.</li>
<li>In the <em>Customer Payments</em> section, fill <em>Maturity Margin</em> for
setting the number of days to last after the due date to consider an
invoice as unpaid.</li>
</ol>
</div>
<div class="section" id="usage">
Expand All @@ -414,17 +412,18 @@ <h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
<li>Set limits and choose options to compute in credit limit.</li>
<li>Go to <em>Invoicing/Accounting &gt; Customers &gt; Invoices</em> and create new
customer invoices.</li>
<li>Test the restriction trying to create an invoice for the partner for an
amount higher of the limit you have set.</li>
<li>Return to Customer <em>Financial Risk</em> tab and click in amount to view origin.</li>
<li>Test the restriction trying to create an invoice for the partner for
an amount higher of the limit you have set.</li>
<li>Return to Customer <em>Financial Risk</em> tab and click in amount to view
origin.</li>
</ol>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/credit-control/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 to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/credit-control/issues/new?body=module:%20account_financial_risk%0Aversion:%2016.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/credit-control/issues/new?body=module:%20account_financial_risk%0Aversion:%2017.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">
Expand Down Expand Up @@ -461,7 +460,7 @@ <h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/carlosdauden"><img alt="carlosdauden" src="https://github.com/carlosdauden.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/credit-control/tree/16.0/account_financial_risk">OCA/credit-control</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/credit-control/tree/17.0/account_financial_risk">OCA/credit-control</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>
Expand Down
12 changes: 9 additions & 3 deletions account_financial_risk/tests/test_account_financial_risk.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
class TestPartnerFinancialRisk(TransactionCase):
@classmethod
def setUpClass(cls):
super(TestPartnerFinancialRisk, cls).setUpClass()
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT))
(cls.env.ref("base.USD") | cls.env.ref("base.EUR")).active = True
cls.env.user.groups_id |= cls.env.ref("account.group_account_manager")
cls.env.user.groups_id |= cls.env.ref(
"account_financial_risk.group_account_financial_risk_manager"
)
tax_group_taxes = cls.env.ref("account.tax_group_taxes")
main_company = cls.env.ref("base.main_company")
cls.cr.execute(
"UPDATE res_company SET currency_id = %s WHERE id = %s",
Expand Down Expand Up @@ -77,7 +76,14 @@ def setUpClass(cls):
{
"name": "Tax for sale 10%",
"type_tax_use": "sale",
"tax_group_id": tax_group_taxes.id,
"tax_group_id": cls.env["account.tax.group"]
.with_company(cls.env.company.id)
.create(
{
"name": "Tax Group TEST",
}
)
.id,
"amount_type": "percent",
"amount": 10.0,
}
Expand Down
Loading

0 comments on commit 6d95af6

Please sign in to comment.