Skip to content

Commit

Permalink
[FIX] sale_multicompany_reporting_currency: amount_option change
Browse files Browse the repository at this point in the history
Ensure `multicompany_reporting_currency_id` is recomputed when changing the `amount_option` value.
  • Loading branch information
vvrossem committed Apr 23, 2024
1 parent 5e1972c commit 1d9b72d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sale_multicompany_reporting_currency/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _get_multicompany_reporting_currency_id(self):
readonly=True,
)

@api.depends("pricelist_id.currency_id")
@api.depends("company_id.amount_option", "pricelist_id.currency_id")
def _compute_multicompany_reporting_currency_id(self):
multicompany_reporting_currency_id = (
self._get_multicompany_reporting_currency_id()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,26 @@ def test_amount_multicompany_reporting_currency(self):
/ self.sale_order.multicompany_reporting_currency_rate,
1825,
)
# check `amount_multicompany_reporting_currency` is recomputed on
# `amount_option` change
self.env["res.config.settings"].create(
{
"multicompany_reporting_currency": self.currency_euro_id,
"amount_option": "total",
}
).execute()
self.assertAlmostEqual(
self.sale_order.amount_multicompany_reporting_currency, 1825
)
self.env["res.config.settings"].create(
{
"multicompany_reporting_currency": self.currency_euro_id,
"amount_option": "untaxed",
}
).execute()
self.assertAlmostEqual(
self.sale_order.amount_multicompany_reporting_currency, 1750
)
# if we remove Currency from Sale Order we expect
# multicompany_reporting_currency_rate to be 1.0
self.sale_order.currency_id = False
Expand All @@ -105,3 +125,4 @@ def test_amount_multicompany_reporting_currency(self):
self.assertAlmostEqual(
self.sale_order.amount_multicompany_reporting_currency, 600
)

0 comments on commit 1d9b72d

Please sign in to comment.