[IMP] account: Increment new account code till there's no conflict
Purpose ======= Since https://github.com/odoo/odoo/commit/db3e40396232f41d86ec0c5f90e783e77f3e9510 we try to increment the account code on account duplication. Now with this commit with increment the code till there are no other account with the same code in the same company.
This commit is contained in:
@@ -238,9 +238,9 @@ class AccountAccount(models.Model):
|
||||
try:
|
||||
default['code'] = (str(int(self.code) + 10) or '')
|
||||
default.setdefault('name', _("%s (copy)") % (self.name or ''))
|
||||
if self.env['account.account'].search([('code', '=', default['code']),
|
||||
('company_id', '=', default.get('company_id', False) or self.company_id.id)], limit=1):
|
||||
default['code'] = _("%s (copy)") % (self.code or '')
|
||||
while self.env['account.account'].search([('code', '=', default['code']),
|
||||
('company_id', '=', default.get('company_id', False) or self.company_id.id)], limit=1):
|
||||
default['code'] = (str(int(default['code']) + 10) or '')
|
||||
default['name'] = _("%s (copy)") % (self.name or '')
|
||||
except ValueError:
|
||||
default['code'] = _("%s (copy)") % (self.code or '')
|
||||
|
||||
Reference in New Issue
Block a user