Merge lp:~unifield-team/unifield-server/us-1450 into lp:unifield-server
- us-1450
- Merge into trunk
Proposed by
jftempo
Status: | Merged |
---|---|
Merged at revision: | 3933 |
Proposed branch: | lp:~unifield-team/unifield-server/us-1450 |
Merge into: | lp:unifield-server |
Diff against target: |
137 lines (+73/-10) 2 files modified
bin/addons/object_query/query.py (+70/-7) bin/addons/object_query/query_view.xml (+3/-3) |
To merge this branch: | bzr merge lp:~unifield-team/unifield-server/us-1450 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Reviewer Team | Pending | ||
Review via email: mp+300715@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'bin/addons/object_query/query.py' | |||
2 | --- bin/addons/object_query/query.py 2016-06-24 12:00:57 +0000 | |||
3 | +++ bin/addons/object_query/query.py 2016-07-21 08:23:19 +0000 | |||
4 | @@ -509,8 +509,8 @@ | |||
5 | 509 | model_obj = self.pool.get(obj.model) | 509 | model_obj = self.pool.get(obj.model) |
6 | 510 | for field in obj.field_id: | 510 | for field in obj.field_id: |
7 | 511 | all_fields_ids.append(field.id) | 511 | all_fields_ids.append(field.id) |
10 | 512 | col = model_obj._columns[field.name] | 512 | col = model_obj._columns.get(field.name) |
11 | 513 | if hasattr(col, '_properties') and col._properties and not col.store: | 513 | if col and hasattr(col, '_properties') and col._properties and not col.store: |
12 | 514 | if a[0] == 'is_function' or not isinstance(col, fields.related): | 514 | if a[0] == 'is_function' or not isinstance(col, fields.related): |
13 | 515 | field_ids.append(field.id) | 515 | field_ids.append(field.id) |
14 | 516 | 516 | ||
15 | @@ -534,6 +534,62 @@ | |||
16 | 534 | res[obj.id] = target_obj._columns[obj.name].help | 534 | res[obj.id] = target_obj._columns[obj.name].help |
17 | 535 | return res | 535 | return res |
18 | 536 | 536 | ||
19 | 537 | def _is_in_model(self, cr, uid, ids, field_name, args, context=None): | ||
20 | 538 | res = {} | ||
21 | 539 | for f in self.browse(cr, uid, ids, context=context): | ||
22 | 540 | res[f.id] = True | ||
23 | 541 | if f.name not in self.pool.get(f.model_id.model)._columns.keys(): | ||
24 | 542 | res[f.id] = False | ||
25 | 543 | |||
26 | 544 | return res | ||
27 | 545 | |||
28 | 546 | def _search_is_in_model(self, cr, uid, obj, name, args, context=None): | ||
29 | 547 | ''' | ||
30 | 548 | Return all fields which are a function field | ||
31 | 549 | ''' | ||
32 | 550 | if not args: | ||
33 | 551 | return [] | ||
34 | 552 | if context is None: | ||
35 | 553 | context = {} | ||
36 | 554 | |||
37 | 555 | def fill_in_model(model_ids): | ||
38 | 556 | inherit_model_ids = [] | ||
39 | 557 | for obj in self.pool.get('ir.model').browse(cr, uid, model_ids, context=context): | ||
40 | 558 | model_obj = self.pool.get(obj.model) | ||
41 | 559 | |||
42 | 560 | if model_obj._inherits: | ||
43 | 561 | for inh_model_name in model_obj._inherits.keys(): | ||
44 | 562 | inh_model_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', inh_model_name)], context=context) | ||
45 | 563 | for inh_model_id in inh_model_ids: | ||
46 | 564 | if inh_model_id not in model_ids: | ||
47 | 565 | inherit_model_ids.append(inh_model_id) | ||
48 | 566 | |||
49 | 567 | for field in obj.field_id: | ||
50 | 568 | if field.name not in model_obj._columns.keys(): | ||
51 | 569 | not_in_model.append(field.id) | ||
52 | 570 | else: | ||
53 | 571 | in_model.append(field.id) | ||
54 | 572 | |||
55 | 573 | if inherit_model_ids: | ||
56 | 574 | fill_in_model(inherit_model_ids) | ||
57 | 575 | |||
58 | 576 | for a in args: | ||
59 | 577 | if a[0] == 'is_in_model': | ||
60 | 578 | field_ids = [] | ||
61 | 579 | all_fields_ids = [] | ||
62 | 580 | model_ids = context.get('model_ids', [(6,0,[])])[0][2] | ||
63 | 581 | |||
64 | 582 | if not model_ids: | ||
65 | 583 | model_ids = self.pool.get('ir.model').search(cr, uid, [], context=context) | ||
66 | 584 | |||
67 | 585 | in_model = [] | ||
68 | 586 | not_in_model = [] | ||
69 | 587 | fill_in_model(model_ids) | ||
70 | 588 | |||
71 | 589 | if (a[1] == '=' and a[2] == False) or (a[1] == '!=' and a[2] == True): | ||
72 | 590 | return [('id', 'in', not_in_model)] | ||
73 | 591 | else: | ||
74 | 592 | return [('id', 'in', in_model)] | ||
75 | 537 | 593 | ||
76 | 538 | _columns = { | 594 | _columns = { |
77 | 539 | 'help': fields.function(_get_help, method=True, type='char', size='10000', string='Help'), | 595 | 'help': fields.function(_get_help, method=True, type='char', size='10000', string='Help'), |
78 | @@ -542,16 +598,23 @@ | |||
79 | 542 | method=True, | 598 | method=True, |
80 | 543 | type='many2one', relation='ir.model', | 599 | type='many2one', relation='ir.model', |
81 | 544 | string='Model'), | 600 | string='Model'), |
84 | 545 | 'is_function': fields.function(_is_function, | 601 | 'is_function': fields.function(_is_function, |
85 | 546 | fnct_search=_search_function, | 602 | fnct_search=_search_function, |
86 | 547 | method=True, | 603 | method=True, |
87 | 548 | type='boolean', string='Is function ?'), | 604 | type='boolean', string='Is function ?'), |
90 | 549 | 'is_unsearchable': fields.function(_is_function, | 605 | 'is_unsearchable': fields.function(_is_function, |
91 | 550 | fnct_search=_search_function, | 606 | fnct_search=_search_function, |
92 | 551 | method=True, | 607 | method=True, |
93 | 552 | type='boolean', string='Is searchable ?'), | 608 | type='boolean', string='Is searchable ?'), |
94 | 609 | 'is_in_model': fields.function( | ||
95 | 610 | _is_in_model, | ||
96 | 611 | fnct_search=_search_is_in_model, | ||
97 | 612 | method=True, | ||
98 | 613 | type='boolean', | ||
99 | 614 | string='Is in model ?', | ||
100 | 615 | ), | ||
101 | 553 | } | 616 | } |
103 | 554 | 617 | ||
104 | 555 | def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): | 618 | def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): |
105 | 556 | ''' | 619 | ''' |
106 | 557 | Call the view on context if there is. | 620 | Call the view on context if there is. |
107 | 558 | 621 | ||
108 | === modified file 'bin/addons/object_query/query_view.xml' | |||
109 | --- bin/addons/object_query/query_view.xml 2011-12-30 08:41:01 +0000 | |||
110 | +++ bin/addons/object_query/query_view.xml 2016-07-21 08:23:19 +0000 | |||
111 | @@ -82,7 +82,7 @@ | |||
112 | 82 | <group colspan="4" attrs="{'invisible': [('newquery', '=', True)]}"> | 82 | <group colspan="4" attrs="{'invisible': [('newquery', '=', True)]}"> |
113 | 83 | <notebook colspan="4"> | 83 | <notebook colspan="4"> |
114 | 84 | <page string="Search fields"> | 84 | <page string="Search fields"> |
116 | 85 | <field name="selection_ids" colspan="4" domain="[('model_search_id', 'in', model_ids), ('is_unsearchable', '=', False)]" nolabel="1" mode="tree" | 85 | <field name="selection_ids" colspan="4" domain="[('model_search_id', 'in', model_ids), ('is_unsearchable', '=', False), ('is_in_model', '=', True)]" nolabel="1" mode="tree" |
117 | 86 | context="{'special_tree_id': 'object_query_ir_field_tree', 'special_search_id': 'object_query_ir_field_search', 'model_ids': model_ids}" | 86 | context="{'special_tree_id': 'object_query_ir_field_tree', 'special_search_id': 'object_query_ir_field_search', 'model_ids': model_ids}" |
118 | 87 | > | 87 | > |
119 | 88 | <tree string="Search fields" noteditable="1" editable="top"> | 88 | <tree string="Search fields" noteditable="1" editable="top"> |
120 | @@ -103,7 +103,7 @@ | |||
121 | 103 | </page> | 103 | </page> |
122 | 104 | <page string="Result fields"> | 104 | <page string="Result fields"> |
123 | 105 | <button name="populate_result" type="object" string="Populate from Search Fields" icon="terp-stock_effects-object-colorize" colspan="2"/> | 105 | <button name="populate_result" type="object" string="Populate from Search Fields" icon="terp-stock_effects-object-colorize" colspan="2"/> |
125 | 106 | <field name="result_simple_ids" colspan="4" nolabel="1" mode="tree" context="{'model_ids': model_ids, 'special_tree_id': 'object_query_ir_field_tree', 'special_search_id': 'object_query_ir_field_search'}" domain="[('model_search_id', 'in', model_ids)]"> | 106 | <field name="result_simple_ids" colspan="4" nolabel="1" mode="tree" context="{'model_ids': model_ids, 'special_tree_id': 'object_query_ir_field_tree', 'special_search_id': 'object_query_ir_field_search'}" domain="[('model_search_id', 'in', model_ids), ('is_in_model', '=', True)]"> |
126 | 107 | <tree string="Result fields" editable="top" noteditable="1"> | 107 | <tree string="Result fields" editable="top" noteditable="1"> |
127 | 108 | <field name="field_description" /> | 108 | <field name="field_description" /> |
128 | 109 | <field name="help" /> | 109 | <field name="help" /> |
129 | @@ -123,7 +123,7 @@ | |||
130 | 123 | </field> | 123 | </field> |
131 | 124 | </page> | 124 | </page> |
132 | 125 | <page string="Group by fields"> | 125 | <page string="Group by fields"> |
134 | 126 | <field name="group_by_ids" colspan="4" domain="[('model_search_id', 'in', model_ids), ('ttype', 'not in', ('related', 'one2many', 'many2many')), ('is_function', '=', False)]" | 126 | <field name="group_by_ids" colspan="4" domain="[('model_search_id', 'in', model_ids), ('ttype', 'not in', ('related', 'one2many', 'many2many')), ('is_function', '=', False), ('is_in_model', '=', True)]" |
135 | 127 | nolabel="1" mode="tree,search" context="{'special_tree_id': 'object_query_ir_field_tree', 'special_search_id': 'object_query_ir_field_search', 'model_ids': model_ids}"> | 127 | nolabel="1" mode="tree,search" context="{'special_tree_id': 'object_query_ir_field_tree', 'special_search_id': 'object_query_ir_field_search', 'model_ids': model_ids}"> |
136 | 128 | <tree string="Group by fields" noteditable="1" editable="top"> | 128 | <tree string="Group by fields" noteditable="1" editable="top"> |
137 | 129 | <field name="field_description" /> | 129 | <field name="field_description" /> |