From 1d843884e861252e395e0818b0fbf8aa074cd9d2 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 27 Jun 2016 13:45:31 +0200 Subject: [PATCH] [FIX] account: Empty list with get_default function in "ir.values" The function get_default in "ir.values" can return an empty list. This is why checking that the result of this function is a list was not enough. --- addons/account/models/res_config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/models/res_config.py b/addons/account/models/res_config.py index ee67707c5df..2c52b9062a2 100644 --- a/addons/account/models/res_config.py +++ b/addons/account/models/res_config.py @@ -166,8 +166,8 @@ class AccountConfigSettings(models.TransientModel): ir_values = self.env['ir.values'] taxes_id = ir_values.get_default('product.template', 'taxes_id', company_id = self.company_id.id) supplier_taxes_id = ir_values.get_default('product.template', 'supplier_taxes_id', company_id = self.company_id.id) - self.default_sale_tax_id = isinstance(taxes_id, list) and taxes_id[0] or taxes_id - self.default_purchase_tax_id = isinstance(supplier_taxes_id, list) and supplier_taxes_id[0] or supplier_taxes_id + self.default_sale_tax_id = isinstance(taxes_id, list) and len(taxes_id) > 0 and taxes_id[0] or taxes_id + self.default_purchase_tax_id = isinstance(supplier_taxes_id, list) and len(supplier_taxes_id) > 0 and supplier_taxes_id[0] or supplier_taxes_id return {} @api.onchange('chart_template_id')