From 3dec09079e9fc84c7b7b64cb7dabf7f2e1f9b797 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 17 Jul 2014 14:22:20 +0200 Subject: [PATCH] [FIX] ir_values: fallback when no condition When searching for default values, if we set a condition (e.g. 'type=out_invoice'), fetch also the default values without any condition set. Thanks to the order by clause, the one with a condition have an higher priority than the one without and will not affect existing result. This fixes default journal/currency on an invoice where the journal is retrieved in the onchange_company_id method (domain is forced). Without this patch only ir.values with a domain set will match, opw 610645 --- openerp/addons/base/ir/ir_values.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openerp/addons/base/ir/ir_values.py b/openerp/addons/base/ir/ir_values.py index bf0128dffd6..953d1aad0d4 100644 --- a/openerp/addons/base/ir/ir_values.py +++ b/openerp/addons/base/ir/ir_values.py @@ -310,10 +310,10 @@ class ir_values(osv.osv): (SELECT company_id from res_users where id = %%s) ) %s - ORDER BY v.user_id, u.company_id""" + ORDER BY v.user_id, u.company_id, v.key2""" params = ('default', model, uid, uid) if condition: - query %= 'AND v.key2 = %s' + query %= 'AND (v.key2 = %s OR v.key2 IS NULL)' params += (condition[:200],) else: query %= 'AND v.key2 is NULL'