[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) <nim@odoo.com>
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user