Skip to content

Commit

Permalink
[MIG] sale_order_currency_rate: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sakthi-shan committed Aug 30, 2024
1 parent 1fbd35c commit 9be64d5
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 24 deletions.
5 changes: 5 additions & 0 deletions sale_order_currency_rate/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ Contributors

- Oscar Reyes <[email protected]>

- `Sodexis <https://www.sodexis.com>`__

- SodexisTeam <[email protected]>
- Sakthivel <[email protected]>

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

Expand Down
2 changes: 1 addition & 1 deletion sale_order_currency_rate/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Currency Rate in Sale Order",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"category": "Sales Management",
"website": "https://github.com/OCA/sale-workflow",
"author": "Jarsa, Odoo Community Association (OCA)",
Expand Down
4 changes: 4 additions & 0 deletions sale_order_currency_rate/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
- Oscar Reyes \<<[email protected]>\>

- [Sodexis](https://www.sodexis.com)
- SodexisTeam \<<[email protected]>\>
- Sakthivel \<<[email protected]>\>
5 changes: 5 additions & 0 deletions sale_order_currency_rate/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,11 @@ <h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<ul class="simple">
<li>Oscar Reyes &lt;<a class="reference external" href="mailto:oscar.reyes&#64;jarsa.com">oscar.reyes&#64;jarsa.com</a>&gt;</li>
<li><a class="reference external" href="https://www.sodexis.com">Sodexis</a><ul>
<li>SodexisTeam &lt;<a class="reference external" href="mailto:dev&#64;sodexis.com">dev&#64;sodexis.com</a>&gt;</li>
<li>Sakthivel &lt;<a class="reference external" href="mailto:sakthivel&#64;sodexis.com">sakthivel&#64;sodexis.com</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
4 changes: 4 additions & 0 deletions sale_order_currency_rate/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# copyright 2024 Sodexis
# license OPL-1 (see license file for full copyright and licensing details).

from . import test_sale_order_compute_currency_rate
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# copyright 2024 Sodexis
# license OPL-1 (see license file for full copyright and licensing details).

from odoo.tests.common import TransactionCase


class TestSaleOrderCurrencyRate(TransactionCase):
def setUp(cls):
super().setUp()
cls.company = cls.env["res.company"].create({"name": "Test Company"})
cls.partner = cls.env["res.partner"].create({"name": "Test client"})
cls.currency_eur = cls.env.ref("base.EUR")
cls.currency_usd = cls.env.ref("base.USD")
cls.company.currency_id = cls.currency_usd
cls.product = cls.env.ref("product.product_product_9")
cls.sale_order = cls.env["sale.order"].create(
{
"company_id": cls.company.id,
"currency_id": cls.currency_eur.id,
"date_order": "2024-08-30",
"partner_id": cls.partner.id,
"order_line": [
(
0,
0,
{
"name": cls.product.name,
"product_id": cls.product.id,
"product_uom_qty": 5.0,
"product_uom": cls.product.uom_id.id,
"price_unit": 10,
},
)
],
}
)
cls.sale_order.currency_id = cls.currency_eur

def test_compute_currency_rate_same_currency(self):
self.sale_order.currency_id = self.currency_usd
self.sale_order._compute_currency_rate()
self.assertEqual(self.sale_order.currency_rate, 1.0)
self.assertEqual(self.sale_order.inverse_currency_rate, 1.0)

def test_compute_currency_rate_conversion(self):
self.sale_order._compute_currency_rate()
expected_rate = self.currency_eur._convert(
1.0,
self.currency_usd,
self.company,
self.sale_order.date_order,
round=False,
)
expected_inverse_rate = self.currency_usd._convert(
1.0,
self.currency_eur,
self.company,
self.sale_order.date_order,
round=False,
)
self.assertEqual(self.sale_order.currency_rate, expected_rate)
self.assertEqual(self.sale_order.inverse_currency_rate, expected_inverse_rate)
37 changes: 16 additions & 21 deletions sale_order_currency_rate/views/res_config_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,24 @@
<field name="inherit_id" ref="sale.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath
expr="//div[@name='quotation_order_setting_container']"
expr="//block[@name='quotation_order_setting_container']"
position="inside"
>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
<span class="o_form_label">Show Currency Rate</span>
<div class="text-muted">
Select how to show exchange rate in sale orders.<br />
<b>No:</b> Don't show the exchange rate.<br />
<b>Normal:</b> Foreing currency to company currency.<br />
<b>Inverse:</b> Company currency to foreign currency.<br />
<b>Both:</b> Show both currency rates.
</div>
<div class="mt16">
<field
name="sale_show_currency_rate"
class="o_light_label"
widget="radio"
options="{'horizontal': true}"
/>
</div>
</div>
</div>
<setting id="sale_show_currency_rate" string="Show Currency Rate">
<span>
Select how to show exchange rate in sale orders.<br />
<b>No:</b> Don't show the exchange rate.<br />
<b>Normal:</b> Foreing currency to company currency.<br />
<b>Inverse:</b> Company currency to foreign currency.<br />
<b>Both:</b> Show both currency rates.
</span>
<field
name="sale_show_currency_rate"
class="o_light_label mt16"
widget="radio"
options="{'horizontal': true}"
/>
</setting>
</xpath>
</field>
</record>
Expand Down
4 changes: 2 additions & 2 deletions sale_order_currency_rate/views/sale_order.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
<xpath expr="//field[@name='currency_id']" position="after">
<field
name="currency_rate"
attrs="{'invisible': [('sale_show_currency_rate', 'in', ['no', 'inverse'])]}"
invisible="sale_show_currency_rate in ['no', 'inverse']"
/>
<field
name="inverse_currency_rate"
attrs="{'invisible': [('sale_show_currency_rate', 'in', ['no', 'normal'])]}"
invisible="sale_show_currency_rate in ['no', 'normal']"
/>
<field name="sale_show_currency_rate" invisible="1" />
</xpath>
Expand Down

0 comments on commit 9be64d5

Please sign in to comment.