From 873e2e55afab532d2d442b81e3c871ee76540d06 Mon Sep 17 00:00:00 2001 From: Swapnesh Shah Date: Sat, 14 Mar 2020 15:46:10 +0000 Subject: [PATCH] [FIX] account: Compute root with single character code Fixes #47147 Followup on 39e2dfca0a4a2cf641a50ee9af510180fff6eb9c and 737eaf93330b7c4e5ff16311c92f1ad17be0cf72 Before this commit, Accounts with single character code was setting non-existing `root_id` which crashes on Grouping by using that field. (and also Accounts were not visible search panel) With this commit we support computing `root_id` with Single Character. closes odoo/odoo#48261 X-original-commit: d93ccdc5a25c061468870359ad8f749496140d19 Signed-off-by: Laurent Smet --- 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 fdaf8745619..81fee22bd30 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -454,7 +454,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 = (ord(record.code[0]) * 1000 + ord(record.code[1:2] or ' ')) if record.code else False + record.root_id = (ord(record.code[0]) * 1000 + ord(record.code[1:2] or '\x00')) if record.code else False @api.depends('code') def _compute_account_group(self):