Skip to content
Snippets Groups Projects
Commit b6834a96 authored by jbw's avatar jbw Committed by jbw-odoo
Browse files

[FIX] base: keep company currency active


This commit aims at preventing the deactivation of a company currency.
Was the issue on 2852452 support ticket (v14). But it seems appropriate to merge it in 13.0 as it is probably a good idea that a company currency always stays active.

How to reproduce bug:
In 13.0:
Install accounting with demo data > activate multi currency in settings > deactivate usd > create new invoice > select eur currency > cannot set usd currency back on invoice

Reconcile JS traceback in 14.0:
Install accounting with demo data > activate multi currency in settings > deactivate usd > go to accounting dashboard > click on reconcile 7 items on Bank journal > click on any “customer/vendor matching” line.

closes odoo/odoo#104819

Task: 2852452
X-original-commit: 1e336810
Signed-off-by: default avatarQuentin De Paoli <qdp@odoo.com>
parent e9707e9e
No related branches found
No related tags found
No related merge requests found
......@@ -26687,3 +26687,9 @@ msgstr ""
#: model:res.country,name:base.ax
msgid "Åland Islands"
msgstr ""
#. module: base
#: code:addons/base/models/res_currency.py:0
#, python-format
msgid "This currency is set on a company and therefore must be active."
msgstr ""
......@@ -8,6 +8,7 @@ import time
import traceback
from odoo import api, fields, models, tools, _
from odoo.exceptions import UserError
_logger = logging.getLogger(__name__)
......@@ -45,6 +46,12 @@ class Currency(models.Model):
('rounding_gt_zero', 'CHECK (rounding>0)', 'The rounding factor must be greater than 0!')
]
@api.constrains('active')
def _check_company_currency_stays_active(self):
currencies = self.filtered(lambda c: not c.active)
if self.env['res.company'].search([('currency_id', 'in', currencies.ids)]):
raise UserError(_("This currency is set on a company and therefore must be active."))
def _get_rates(self, company, date):
if not self.ids:
return {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment