Skip to content

Commit 1d19c31

Browse files
[MIG] sale_financial_risk: Migration to 19.0
1 parent 3a1bd4c commit 1d19c31

File tree

9 files changed

+169
-49
lines changed

9 files changed

+169
-49
lines changed

sale_financial_risk/README.rst

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ Sale Financial Risk
2121
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
2222
:alt: License: AGPL-3
2323
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcredit--control-lightgray.png?logo=github
24-
:target: https://github.com/OCA/credit-control/tree/18.0/sale_financial_risk
24+
:target: https://github.com/OCA/credit-control/tree/19.0/sale_financial_risk
2525
:alt: OCA/credit-control
2626
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
27-
:target: https://translation.odoo-community.org/projects/credit-control-18-0/credit-control-18-0-sale_financial_risk
27+
:target: https://translation.odoo-community.org/projects/credit-control-19-0/credit-control-19-0-sale_financial_risk
2828
:alt: Translate me on Weblate
2929
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
30-
:target: https://runboat.odoo-community.org/builds?repo=OCA/credit-control&target_branch=18.0
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/credit-control&target_branch=19.0
3131
:alt: Try me on Runboat
3232

3333
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -61,7 +61,7 @@ Bug Tracker
6161
Bugs are tracked on `GitHub Issues <https://github.com/OCA/credit-control/issues>`_.
6262
In case of trouble, please check there if your issue has already been reported.
6363
If you spotted it first, help us to smash it by providing a detailed and welcomed
64-
`feedback <https://github.com/OCA/credit-control/issues/new?body=module:%20sale_financial_risk%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
64+
`feedback <https://github.com/OCA/credit-control/issues/new?body=module:%20sale_financial_risk%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
6565

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

@@ -76,15 +76,18 @@ Authors
7676
Contributors
7777
------------
7878

79-
- `Tecnativa <https://www.tecnativa.com>`__:
79+
- `Tecnativa <https://www.tecnativa.com>`__:
8080

81-
- Carlos Dauden
82-
- Pedro M. Baeza
83-
- Ernesto Tejeda
84-
- Stefan Ungureanu
81+
- Carlos Dauden
82+
- Pedro M. Baeza
83+
- Ernesto Tejeda
84+
- Stefan Ungureanu
8585

86-
- Agathe Mollé <agathe.molle@savoirfairelinux.com>
87-
- Ugne Sinkeviciene <ugne@versada.eu>
86+
- Agathe Mollé <agathe.molle@savoirfairelinux.com>
87+
- Ugne Sinkeviciene <ugne@versada.eu>
88+
- `Studio73 <https://www.studio73.es/>`__:
89+
90+
- Pablo Cortés
8891

8992
Maintainers
9093
-----------
@@ -99,6 +102,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
99102
mission is to support the collaborative development of Odoo features and
100103
promote its widespread use.
101104

102-
This module is part of the `OCA/credit-control <https://github.com/OCA/credit-control/tree/18.0/sale_financial_risk>`_ project on GitHub.
105+
This module is part of the `OCA/credit-control <https://github.com/OCA/credit-control/tree/19.0/sale_financial_risk>`_ project on GitHub.
103106

104107
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

sale_financial_risk/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "Sale Financial Risk",
66
"summary": "Manage partner risk in sales orders",
7-
"version": "18.0.1.0.6",
7+
"version": "19.0.1.0.0",
88
"category": "Sales Management",
99
"license": "AGPL-3",
1010
"author": "Tecnativa, Odoo Community Association (OCA)",

sale_financial_risk/models/payment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
class PaymentTransaction(models.Model):
88
_inherit = "payment.transaction"
99

10-
def _set_authorized(self):
10+
def _set_authorized(self, **kwargs):
1111
"""Bypass risk for sale confirmation triggered by this method"""
1212
return super(
1313
PaymentTransaction, self.with_context(bypass_risk=True)
14-
)._set_authorized()
14+
)._set_authorized(**kwargs)
1515

1616
def _post_process(self):
1717
"""Bypass risk for sale confirmation and invoice creation triggered

sale_financial_risk/models/res_partner.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
33

44
from odoo import api, fields, models
5+
from odoo.fields import Domain
56

67

78
class ResPartner(models.Model):
@@ -25,10 +26,21 @@ class ResPartner(models.Model):
2526

2627
def _get_risk_sale_order_domain(self):
2728
risk_states = self.env["sale.order"]._get_risk_states()
28-
return self._get_risk_company_domain() + [
29-
("state", "in", risk_states),
30-
("risk_partner_id", "in", self.mapped("commercial_partner_id").ids),
31-
]
29+
return Domain.AND(
30+
[
31+
self._get_risk_company_domain(),
32+
Domain(
33+
[
34+
("state", "in", risk_states),
35+
(
36+
"risk_partner_id",
37+
"in",
38+
self.mapped("commercial_partner_id").ids,
39+
),
40+
]
41+
),
42+
]
43+
)
3244

3345
@api.depends(
3446
"sale_order_ids.order_line.risk_amount",

sale_financial_risk/models/sale.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def _compute_risk_amount(self):
105105
qty = max(qty, line.qty_delivered)
106106
risk_qty = float_round(
107107
qty - line.qty_invoiced,
108-
precision_rounding=line.product_uom.rounding or 0.01,
108+
precision_rounding=line.product_uom_id.rounding or 0.01,
109109
)
110110
# There is no risk if the line hasn't stock moves to deliver
111111
# Added hasattr condition because fails in post-migration compute

sale_financial_risk/readme/CONTRIBUTORS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
- Stefan Ungureanu
66
- Agathe Mollé \<<agathe.molle@savoirfairelinux.com>\>
77
- Ugne Sinkeviciene \<<ugne@versada.eu>\>
8+
- [Studio73](https://www.studio73.es/):
9+
- Pablo Cortés

sale_financial_risk/static/description/index.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ <h1>Sale Financial Risk</h1>
374374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375375
!! source digest: sha256:e01c8b7e6ffe45c71c56e0b59574a8cfb43644087f75958793cd0a2244e82fac
376376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<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/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/credit-control/tree/18.0/sale_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-18-0/credit-control-18-0-sale_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=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
377+
<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/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/credit-control/tree/19.0/sale_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-19-0/credit-control-19-0-sale_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=19.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378378
<p>Extends Partner Financial Risk to manage sales orders.</p>
379379
<p>Adds a new risk amount field in sale order line to compute risk based on
380380
the difference between ordered quantity (or delivered in some cases) and
@@ -408,7 +408,7 @@ <h2><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h2>
408408
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/credit-control/issues">GitHub Issues</a>.
409409
In case of trouble, please check there if your issue has already been reported.
410410
If you spotted it first, help us to smash it by providing a detailed and welcomed
411-
<a class="reference external" href="https://github.com/OCA/credit-control/issues/new?body=module:%20sale_financial_risk%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
411+
<a class="reference external" href="https://github.com/OCA/credit-control/issues/new?body=module:%20sale_financial_risk%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
412412
<p>Do not contact contributors directly about support or help with technical issues.</p>
413413
</div>
414414
<div class="section" id="credits">
@@ -431,6 +431,10 @@ <h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
431431
</li>
432432
<li>Agathe Mollé &lt;<a class="reference external" href="mailto:agathe.molle&#64;savoirfairelinux.com">agathe.molle&#64;savoirfairelinux.com</a>&gt;</li>
433433
<li>Ugne Sinkeviciene &lt;<a class="reference external" href="mailto:ugne&#64;versada.eu">ugne&#64;versada.eu</a>&gt;</li>
434+
<li><a class="reference external" href="https://www.studio73.es/">Studio73</a>:<ul>
435+
<li>Pablo Cortés</li>
436+
</ul>
437+
</li>
434438
</ul>
435439
</div>
436440
<div class="section" id="maintainers">
@@ -442,7 +446,7 @@ <h3><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h3>
442446
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
443447
mission is to support the collaborative development of Odoo features and
444448
promote its widespread use.</p>
445-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/credit-control/tree/18.0/sale_financial_risk">OCA/credit-control</a> project on GitHub.</p>
449+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/credit-control/tree/19.0/sale_financial_risk">OCA/credit-control</a> project on GitHub.</p>
446450
<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>
447451
</div>
448452
</div>

sale_financial_risk/tests/test_partner_sale_risk.py

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright 2016-2018 Tecnativa - Carlos Dauden
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
33

4-
from odoo import fields
4+
from odoo import Command, fields
55

66
from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT, BaseCommon
77

@@ -11,17 +11,38 @@ class TestPartnerSaleRisk(BaseCommon):
1111
def setUpClass(cls):
1212
super().setUpClass()
1313
cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT))
14-
cls.env.user.groups_id |= cls.env.ref(
14+
cls.env.user.group_ids |= cls.env.ref(
1515
"account_financial_risk.group_account_financial_risk_manager"
1616
)
17+
cls.account_income = cls.env["account.account"].create(
18+
{
19+
"name": "Test Income Account",
20+
"code": "TESTINC",
21+
"account_type": "income",
22+
"company_ids": [Command.set([cls.env.company.id])],
23+
}
24+
)
25+
cls.account_receivable = cls.env["account.account"].create(
26+
{
27+
"name": "Test Receivable Account",
28+
"code": "TESTREC",
29+
"account_type": "asset_receivable",
30+
"company_ids": [Command.set([cls.env.company.id])],
31+
}
32+
)
1733
cls.partner = cls.env["res.partner"].create(
18-
{"name": "Partner test", "customer_rank": 1}
34+
{
35+
"name": "Partner test",
36+
"customer_rank": 1,
37+
"property_account_receivable_id": cls.account_receivable.id,
38+
}
1939
)
2040
cls.product = cls.env["product.product"].create(
2141
{
2242
"sale_ok": True,
2343
"taxes_id": [],
2444
"name": "Test Product",
45+
"property_account_income_id": cls.account_income.id,
2546
}
2647
)
2748
cls.product.invoice_policy = "order"
@@ -33,6 +54,14 @@ def setUpClass(cls):
3354
cls.USD = cls.env.ref("base.USD")
3455
cls.sale_order = cls.create_sale_order(cls.main_currency, cls.env.company)
3556
cls.env.user.lang = "en_US"
57+
cls.journal = cls.env["account.journal"].create(
58+
{
59+
"name": "Test Sale Journal",
60+
"code": "TSJ",
61+
"type": "sale",
62+
"company_id": cls.env.company.id,
63+
}
64+
)
3665

3766
@classmethod
3867
def create_sale_order(cls, currency, company):
@@ -43,16 +72,14 @@ def create_sale_order(cls, currency, company):
4372
"currency_id": currency.id,
4473
"company_id": company.id,
4574
"order_line": [
46-
(
47-
0,
48-
0,
75+
Command.create(
4976
{
5077
"name": cls.product.name,
5178
"product_id": cls.product.id,
5279
"product_uom_qty": 1,
53-
"product_uom": cls.product.uom_id.id,
80+
"product_uom_id": cls.product.uom_id.id,
5481
"price_unit": 115.0,
55-
"tax_id": False,
82+
"tax_ids": False,
5683
"company_id": company.id,
5784
},
5885
)
@@ -155,7 +182,8 @@ def test_compute_risk_amount(self):
155182
[
156183
("type", "=", "sale"),
157184
("company_id", "=", self.env.company.id),
158-
]
185+
],
186+
limit=1,
159187
)
160188
ref_wiz_obj = self.env["account.move.reversal"].with_context(
161189
active_model="account.move", active_ids=[invoice.id]

0 commit comments

Comments
 (0)