Skip to content

Commit

Permalink
[MIG] sale_financial_risk: Migration to 13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MiquelRForgeFlow committed Jun 16, 2020
1 parent 120c4a6 commit c533a66
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 90 deletions.
12 changes: 6 additions & 6 deletions sale_financial_risk/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ Sale 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/12.0/sale_financial_risk
:target: https://github.com/OCA/credit-control/tree/13.0/sale_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-12-0/credit-control-12-0-sale_financial_risk
:target: https://translation.odoo-community.org/projects/credit-control-13-0/credit-control-13-0-sale_financial_risk
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/262/12.0
:target: https://runbot.odoo-community.org/runbot/262/13.0
:alt: Try me on Runbot

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

Extends Partner Financial Risk to manage sales orders.

Expand Down Expand Up @@ -53,7 +53,7 @@ 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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/credit-control/issues/new?body=module:%20sale_financial_risk%0Aversion:%2012.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:%20sale_financial_risk%0Aversion:%2013.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.

Expand Down Expand Up @@ -89,6 +89,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/credit-control <https://github.com/OCA/credit-control/tree/12.0/sale_financial_risk>`_ project on GitHub.
This module is part of the `OCA/credit-control <https://github.com/OCA/credit-control/tree/13.0/sale_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 sale_financial_risk/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Sale Financial Risk",
"summary": "Manage partner risk in sales orders",
"version": "12.0.2.0.0",
"version": "13.0.1.0.0",
"category": "Sales Management",
"license": "AGPL-3",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand Down
2 changes: 1 addition & 1 deletion sale_financial_risk/i18n/sale_financial_risk.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
Expand Down
24 changes: 0 additions & 24 deletions sale_financial_risk/migrations/12.0.2.0.0/post-migration.py

This file was deleted.

40 changes: 0 additions & 40 deletions sale_financial_risk/migrations/12.0.2.0.0/pre-migration.py

This file was deleted.

8 changes: 4 additions & 4 deletions sale_financial_risk/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ResPartner(models.Model):
def _get_risk_sale_order_domain(self):
# When p is NewId object instance bool(p.id) is False
commercial_partners = self.filtered(
lambda p: (p.customer and p.id and p == p.commercial_partner_id)
lambda p: (p.customer_rank and p.id and p == p.commercial_partner_id)
)
return self._get_risk_company_domain() + [
("state", "=", "sale"),
Expand All @@ -42,9 +42,9 @@ def _compute_risk_sale_order(self):
orderby="id",
)
for group in orders_group:
self.browse(
group["commercial_partner_id"][0], self._prefetch
).risk_sale_order = group["risk_amount"]
self.browse(group["commercial_partner_id"][0]).risk_sale_order = group[
"risk_amount"
]

@api.model
def _risk_field_list(self):
Expand Down
3 changes: 1 addition & 2 deletions sale_financial_risk/models/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
class SaleOrder(models.Model):
_inherit = "sale.order"

@api.multi
def action_confirm(self):
if not self.env.context.get("bypass_risk", False):
risk_amount = self.currency_id._convert(
Expand Down Expand Up @@ -42,7 +41,7 @@ def action_confirm(self):
)
.action_show()
)
return super(SaleOrder, self).action_confirm()
return super().action_confirm()


class SaleOrderLine(models.Model):
Expand Down
6 changes: 3 additions & 3 deletions sale_financial_risk/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Sale Financial Risk</h1>
!! 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/credit-control/tree/12.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" href="https://translation.odoo-community.org/projects/credit-control-12-0/credit-control-12-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" href="https://runbot.odoo-community.org/runbot/262/12.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/credit-control/tree/13.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" href="https://translation.odoo-community.org/projects/credit-control-13-0/credit-control-13-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" href="https://runbot.odoo-community.org/runbot/262/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>Extends Partner Financial Risk to manage sales orders.</p>
<p>Adds a new risk amount field in sale order line to compute risk based on the
difference between ordered quantity (or delivered in some cases) and invoiced
Expand Down Expand Up @@ -400,7 +400,7 @@ <h1><a class="toc-backref" href="#id2">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 smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/credit-control/issues/new?body=module:%20sale_financial_risk%0Aversion:%2012.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:%20sale_financial_risk%0Aversion:%2013.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 @@ -430,7 +430,7 @@ <h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
<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/credit-control/tree/12.0/sale_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/13.0/sale_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
16 changes: 7 additions & 9 deletions sale_financial_risk/tests/test_partner_sale_risk.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def setUpClass(cls):
super(TestPartnerSaleRisk, cls).setUpClass()
cls.env.user.groups_id |= cls.env.ref("sales_team.group_sale_manager")
cls.partner = cls.env["res.partner"].create(
{"name": "Partner test", "customer": True}
{"name": "Partner test", "customer_rank": 1}
)
cls.product = cls.env.ref("product.product_product_2")
cls.product.invoice_policy = "order"
Expand Down Expand Up @@ -71,7 +71,7 @@ def test_compute_risk_amount(self):
# Now the amount to be invoiced must 100
self.assertEqual(self.partner.risk_sale_order, 100.0)
self.assertFalse(self.partner.risk_exception)
# If we set a risk_sale_order_limit to 99, risk_excepion must be True
# If we set a risk_sale_order_limit to 99, risk_exception must be True
self.partner.risk_sale_order_limit = 99.0
self.assertTrue(self.partner.risk_exception)
# If we create and validate an invoice from the sale order then the
Expand All @@ -85,21 +85,19 @@ def test_compute_risk_amount(self):
self.assertAlmostEqual(self.partner.risk_invoice_draft, 100.0)
self.assertAlmostEqual(self.partner.risk_sale_order, 0)
invoice = self.sale_order.invoice_ids
invoice.with_context(bypass_risk=True).action_invoice_open()
invoice.with_context(bypass_risk=True).post()
self.assertAlmostEqual(self.partner.risk_sale_order, 0)
self.assertAlmostEqual(self.partner.risk_invoice_draft, 0.0)
self.assertAlmostEqual(self.partner.risk_invoice_open, 100.0)
self.assertFalse(self.partner.risk_exception)
# After that, if we create and validate a Credit Note from the invoice
# then the amount to be invoiced must be 100 again
# and risk_exception must be True
ref_wiz_obj = self.env["account.invoice.refund"].with_context(
active_id=invoice.id, active_ids=[invoice.id]
ref_wiz_obj = self.env["account.move.reversal"].with_context(
active_model="account.move", active_ids=[invoice.id]
)
ref_wiz = ref_wiz_obj.create(
{"description": "testing", "filter_refund": "modify"}
)
res = ref_wiz.invoice_refund()
ref_wiz = ref_wiz_obj.create({"reason": "testing", "refund_method": "modify"})
res = ref_wiz.reverse_moves()
self.assertAlmostEqual(self.partner.risk_invoice_draft, 100.0)
self.assertAlmostEqual(self.partner.risk_sale_order, 0.0)
# The way to re-invoice a sale order is creating a refund with
Expand Down

0 comments on commit c533a66

Please sign in to comment.