[FIX] account: account with single character code

The creation of an account with a single character code crashes.

opw-2176764

closes odoo/odoo#43455

X-original-commit: 7b1e881e60d6424f7b3a676c06a4b5b8a222d025
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Nicolas Martinelli
2020-01-17 09:07:04 +00:00
parent 4bb5ba65a6
commit e3f1802d4c
+1 -1
View File
@@ -448,7 +448,7 @@ class AccountAccount(models.Model):
# This field should have been a char, but the aim is to use it in a side panel view with hierarchy, and it's only supported by many2one fields so far.
# So instead, we make it a many2one to a psql view with what we need as records.
for record in self:
record.root_id = record.code and (ord(record.code[0]) * 1000 + ord(record.code[1])) or False
record.root_id = (ord(record.code[0]) * 1000 + ord(record.code[1:2] or ' ')) if record.code else False
@api.depends('code')
def _compute_account_group(self):