From 862f28dd5c594d4843b1d250387da2db40c71477 Mon Sep 17 00:00:00 2001 From: "jerome hanke (jhk)" Date: Wed, 22 Jan 2020 14:03:59 +0000 Subject: [PATCH] [FIX] account: keep the code leading zeros on account duplication Steps to reproduce: - install accounting - go to accounting > configuration > charts of account - create a chart of account with a code containing leading zero's (ex: 000022) - duplicate the previously created chart of account Previous behavior: leading zero's are not kept trough duplication Current behavior: the new code is padded with leading zero's to keep the same length opw-2172816 closes odoo/odoo#43802 X-original-commit: c458c8ecee6b544b4056ccf5a9af591622238182 Signed-off-by: Nicolas Martinelli (nim) --- addons/account/models/account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/models/account.py b/addons/account/models/account.py index bff268683e5..a5635bdfade 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -593,7 +593,7 @@ class AccountAccount(models.Model): if default.get('code', False): return super(AccountAccount, self).copy(default) try: - default['code'] = (str(int(self.code) + 10) or '') + default['code'] = (str(int(self.code) + 10) or '').zfill(len(self.code)) default.setdefault('name', _("%s (copy)") % (self.name or '')) while self.env['account.account'].search([('code', '=', default['code']), ('company_id', '=', default.get('company_id', False) or self.company_id.id)], limit=1):