Merge lp:~openerp-dev/openobject-server/trunk-bug-780418-rga into lp:openobject-server

Proposed by Ravi Gadhia (OpenERP)
Status: Merged
Merged at revision: 3422
Proposed branch: lp:~openerp-dev/openobject-server/trunk-bug-780418-rga
Merge into: lp:openobject-server
Diff against target: 62 lines (+34/-2)
3 files modified
openerp/addons/base/__openerp__.py (+1/-0)
openerp/addons/base/ir/ir_values.py (+9/-2)
openerp/addons/base/test/test_ir_values.yml (+24/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/trunk-bug-780418-rga
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+60901@code.launchpad.net
To post a comment you must log in.
3412. By Vo Minh Thu

[MERGE] yml test: more explicit message when some data is missing.

3413. By Vo Minh Thu

[MERGE] slightly improved log message for cron jobs.

3414. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

3415. By Vo Minh Thu

[MERGE] merged fix for res_lang.

3416. By Vo Minh Thu

[REF] consistent, grepable ir.values object naming.

3417. By Vo Minh Thu

[FIX] res_lang: when testing if there is some default value on res.partner, pass it as a list of strings, not as a string.

3418. By Vo Minh Thu

[Fix] Set default value for current login user

3419. By Vo Minh Thu

[IMP] ir_value: forgot to add some comment.

Revision history for this message
Vo Minh Thu (thu) wrote :

Hello Ravi,

As you can see, I've added a little comment to your code and a small test case.
- Can you confirm that it tests what you intended to fix.
- Would you please add such test cases in your next merge proposals? We really want to better test the framework.

(Actually these tests are just the very minimum as they don't test much but the specific reported bug, but it is better than nothing.)

Revision history for this message
Ravi Gadhia (OpenERP) (rga-openerp) wrote :

Hello Vo Minh Thu,
      Thank you for add yml test and merge.
      ok, sure from next merge proposals, I will create yml test for such a specific test case.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openerp/addons/base/__openerp__.py'
2--- openerp/addons/base/__openerp__.py 2011-03-02 08:35:38 +0000
3+++ openerp/addons/base/__openerp__.py 2011-05-17 14:17:50 +0000
4@@ -94,6 +94,7 @@
5 'test/bug_lp541545.xml',
6 'test/test_osv_expression.yml',
7 'test/test_ir_rule.yml', # <-- These tests modify/add/delete ir_rules.
8+ 'test/test_ir_values.yml',
9 ],
10 'installable': True,
11 'active': True,
12
13=== modified file 'openerp/addons/base/ir/ir_values.py'
14--- openerp/addons/base/ir/ir_values.py 2010-12-06 13:19:28 +0000
15+++ openerp/addons/base/ir/ir_values.py 2011-05-17 14:17:50 +0000
16@@ -172,8 +172,15 @@
17 else:
18 where.append('res_id=%s')
19 params.append(res_id)
20-
21- where.append('(user_id=%s or (user_id IS NULL)) order by id')
22+ order = 'id'
23+ if key == 'default':
24+ # Make sure we get first the values for specific users, then
25+ # the global values. The map/filter below will retain the first
26+ # value for any given name. The 'order by' will put the null
27+ # values last; this may be postgres specific (it is the
28+ # behavior in postgres at least since 8.2).
29+ order = 'user_id'
30+ where.append('(user_id=%s or (user_id IS NULL)) order by '+ order)
31 params.append(uid)
32 clause = ' and '.join(where)
33 cr.execute('select id,name,value,object,meta, key from ir_values where ' + clause, params)
34
35=== added file 'openerp/addons/base/test/test_ir_values.yml'
36--- openerp/addons/base/test/test_ir_values.yml 1970-01-01 00:00:00 +0000
37+++ openerp/addons/base/test/test_ir_values.yml 2011-05-17 14:17:50 +0000
38@@ -0,0 +1,24 @@
39+ Create some default value for some (non-existing) model, for all users.
40+-
41+ !python {model: ir.values }: |
42+ self.set(cr, uid, 'default', False, 'my_test_ir_value',['unexisting_model'], 'global value')
43+-
44+ Retrieve it.
45+-
46+ !python {model: ir.values }: |
47+ # d is a list of triple (id, name, value)
48+ d = self.get(cr, uid, 'default', False, ['unexisting_model'])
49+ assert d[1] == 'my_test_ir_value'
50+ assert d[2] == 'global_value'
51+-
52+ Do it again but for a specific user.
53+-
54+ !python {model: ir.values }: |
55+ self.set(cr, uid, 'default', False, 'my_test_ir_value',['unexisting_model'], 'specific value', preserve_user=True)
56+-
57+ Retrieve it and check it is the one for the current user.
58+-
59+ !python {model: ir.values }: |
60+ d = self.get(cr, uid, 'default', False, ['unexisting_model'])
61+ assert d[1] == 'my_test_ir_value'
62+ assert d[2] == 'specific_value'