{"record":{"id":"8febe56dd9d807d9","repo":"odoo/odoo","slug":"you-cannot-reduce-the-number-of-decimal-places-of","errorCode":null,"errorMessage":"You cannot reduce the number of decimal places of a currency which has already been used to make accounting entries.","messagePattern":"You cannot reduce the number of decimal places of a currency which has already been used to make accounting entries\\.","errorType":"exception","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"addons/account/models/res_currency.py","lineNumber":31,"sourceCode":"        return ','.join(self.env.companies.mapped('account_fiscal_country_id.code'))\n\n    display_rounding_warning = fields.Boolean(string=\"Display Rounding Warning\", compute='_compute_display_rounding_warning',\n        help=\"The warning informs a rounding factor change might be dangerous on res.currency's form view.\")\n    fiscal_country_codes = fields.Char(store=False, default=_get_fiscal_country_codes)\n\n    @api.depends('rounding')\n    def _compute_display_rounding_warning(self):\n        for record in self:\n            record.display_rounding_warning = (\n                record._origin.id and record._origin.rounding != record.rounding\n            )\n\n    def write(self, vals):\n        if 'rounding' in vals:\n            rounding_val = vals['rounding']\n            for record in self:\n                if (rounding_val > record.rounding or rounding_val == 0) and record._has_accounting_entries():\n                    raise UserError(_(\"You cannot reduce the number of decimal places of a currency which has already been used to make accounting entries.\"))\n\n        return super(ResCurrency, self).write(vals)\n\n    def _has_accounting_entries(self):\n        \"\"\" Returns True iff this currency has been used to generate (hence, round)\n        some move lines (either as their foreign currency, or as the main currency).\n        \"\"\"\n        self.ensure_one()\n        return bool(self.env['account.move.line'].sudo().search_count(['|', ('currency_id', '=', self.id), ('company_currency_id', '=', self.id)]))\n\n    def _get_simple_currency_table(self, companies) -> SQL:\n        \"\"\" Helper creating the currency table and returning its definition for basic cases of Odoo reports needing to convert amounts using only the\n        current rates, in a single period.\n        \"\"\"\n        if self._check_currency_table_monocurrency(companies):\n            return self._get_monocurrency_currency_table_sql(companies)\n\n        self._create_currency_table(companies, [('period', None, fields.Date.today())])","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/odoo/odoo/blob/1e661df964b1b264c9cef3ab28430d4785be3fda/addons/account/models/res_currency.py#L13-L49","documentation":"Raised by res.currency.write (addons/account/models/res_currency.py:31) when you increase the rounding value (or set it to 0) of a currency that already has accounting entries. A larger rounding factor means fewer decimal places, which would contradict amounts already computed and stored on move lines, so Odoo refuses the change for used currencies.","triggerScenarios":"write({'rounding': X}) where X > record.rounding (e.g. going from 0.01 to 0.05/1.0) or X == 0, on a currency referenced by any account.move.line.currency_id or company_currency_id (_has_accounting_entries does a sudoed search_count). Decreasing rounding (more decimals) is allowed.","commonSituations":"Fixing a misconfigured currency (e.g. rounding set to 0.01 when it should be 1 for a zero-decimal currency like JPY) after transactions exist; data imports or demo-data corrections on currencies already used by invoices; enabling a new decimal convention on a live database.","solutions":["Keep the historical currency untouched and create a new currency record with the desired rounding, then use it going forward.","Only decrease rounding (more precision) on a used currency — that direction is permitted.","On an empty/test database, remove the accounting entries (or use a fresh DB) and then change rounding."],"exampleFix":"# before\ncurrency.write({'rounding': 1.0})  # UserError: currency already used\n\n# after (new currency for future use)\nnew_cur = currency.copy({'name': currency.name + ' (2dp→0dp)', 'rounding': 1.0})","handlingStrategy":"validation","validationCode":"def can_set_rounding(currency, new_rounding):\n    if new_rounding > currency.rounding or new_rounding == 0:\n        return not currency._has_accounting_entries()\n    return True","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Configure currency rounding correctly before the first transaction.","Allow only precision-increasing edits (smaller rounding) on used currencies.","Need coarser rounding later? Create a new currency instead of editing the used one."],"tags":["odoo","accounting","currency","rounding","configuration"],"backgroundTag":null,"analyzedSha":"1e661df964b1b264c9cef3ab28430d4785be3fda","analyzedAt":"2026-08-15T05:22:16.142Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}