[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
This commit is contained in:
Martin Trigaux 2014-07-17 14:22:20 +02:00
parent 7a928b151a
commit 3dec09079e
1 changed files with 2 additions and 2 deletions

View File

@ -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'