diff --git a/addons/account/models/res_currency.py b/addons/account/models/res_currency.py index 024faf59d3a..5060337d443 100644 --- a/addons/account/models/res_currency.py +++ b/addons/account/models/res_currency.py @@ -36,11 +36,10 @@ class ResCurrency(models.Model): def _has_accounting_entries(self): """ Returns True iff this currency has been used to generate (hence, round) - some move lines (either as their foreign currency, or as the main currency - of their company). + some move lines (either as their foreign currency, or as the main currency). """ self.ensure_one() - return bool(self.env['account.move.line'].search_count(['|', ('currency_id', '=', self.id), ('company_currency_id', '=', self.id)])) + return bool(self.env['account.move.line'].sudo().search_count(['|', ('currency_id', '=', self.id), ('company_currency_id', '=', self.id)])) @api.model def _get_query_currency_table(self, company_ids, conversion_date): diff --git a/addons/account/tests/test_tax.py b/addons/account/tests/test_tax.py index e3ef9370009..0b043c5efe7 100644 --- a/addons/account/tests/test_tax.py +++ b/addons/account/tests/test_tax.py @@ -13,6 +13,16 @@ class TestTaxCommon(AccountTestInvoicingCommon): cls.currency_data['currency'].rounding = 1.0 cls.currency_no_decimal = cls.currency_data['currency'] cls.company_data_2 = cls.setup_company_data('company_2', currency_id=cls.currency_no_decimal.id) + + cls.currency_5_round = cls.env['res.currency'].create({ + 'name': 'Platinum Coin', + 'symbol': 'P$', + 'rounding': 0.05, + 'position': 'after', + 'currency_unit_label': 'Platinum', + 'currency_subunit_label': 'Palladium', + }) + cls.company_data_3 = cls.setup_company_data('company_3', currency_id=cls.currency_5_round.id) cls.env.user.company_id = cls.company_data['company'] cls.fixed_tax = cls.env['account.tax'].create({ @@ -119,7 +129,7 @@ class TestTaxCommon(AccountTestInvoicingCommon): 'amount': 0, }) - cls.tax_5_percent = cls.env['account.tax'].with_company(cls.company_data['company']).create({ + cls.tax_5_percent = cls.env['account.tax'].with_company(cls.company_data_3['company']).create({ 'name': "test_5_percent", 'amount_type': 'percent', 'amount': 5,