Merge lp:~openerp-dev/openobject-server/6.0-opw-35611-rgo into lp:openobject-server/6.0

Proposed by Ravi Gohil (OpenERP)
Status: Merged
Approved by: Naresh(OpenERP)
Approved revision: 3539
Merged at revision: 3605
Proposed branch: lp:~openerp-dev/openobject-server/6.0-opw-35611-rgo
Merge into: lp:openobject-server/6.0
Diff against target: 113 lines (+47/-7)
2 files modified
bin/osv/fields.py (+22/-0)
bin/osv/orm.py (+25/-7)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/6.0-opw-35611-rgo
Reviewer Review Type Date Requested Status
Naresh(OpenERP) (community) Approve
Olivier Dony (Odoo) Pending
Review via email: mp+82121@code.launchpad.net

Description of the change

Hello,

There was an issue with sorting field of multilevel inheritance in tree view.

This fixes the issue.

Regards.

To post a comment you must log in.
Revision history for this message
Naresh(OpenERP) (nch-openerp) :
review: Approve
3540. By Xavier ALT

[IMP] rework _inherits_join_add() calls to not break v6.0 API

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/osv/fields.py'
2--- bin/osv/fields.py 2011-12-15 10:08:55 +0000
3+++ bin/osv/fields.py 2012-03-14 11:34:19 +0000
4@@ -1123,5 +1123,27 @@
5 self.field_id = {}
6
7
8+class column_info(object):
9+ """Struct containing details about an osv column, either one local to
10+ its model, or one inherited via _inherits.
11+
12+ :attr name: name of the column
13+ :attr column: column instance, subclass of osv.fields._column
14+ :attr parent_model: if the column is inherited, name of the model
15+ that contains it, None for local columns.
16+ :attr parent_column: the name of the column containing the m2o
17+ relationship to the parent model that contains
18+ this column, None for local columns.
19+ :attr original_parent: if the column is inherited, name of the original
20+ parent model that contains it i.e in case of multilevel
21+ inheritence, None for local columns.
22+ """
23+ def __init__(self, name, column, parent_model=None, parent_column=None, original_parent=None):
24+ self.name = name
25+ self.column = column
26+ self.parent_model = parent_model
27+ self.parent_column = parent_column
28+ self.original_parent = original_parent
29+
30 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
31
32
33=== modified file 'bin/osv/orm.py'
34--- bin/osv/orm.py 2012-03-09 07:45:27 +0000
35+++ bin/osv/orm.py 2012-03-14 11:34:19 +0000
36@@ -2140,6 +2140,7 @@
37 class orm(orm_template):
38 _sql_constraints = []
39 _table = None
40+ _all_columns = {}
41 _protected = ['read', 'write', 'create', 'default_get', 'perm_read', 'unlink', 'fields_get', 'fields_view_get', 'search', 'name_get', 'distinct_field_get', 'name_search', 'copy', 'import_data', 'search_count', 'exists']
42 __logger = logging.getLogger('orm')
43 __schema = logging.getLogger('orm.schema')
44@@ -2293,7 +2294,7 @@
45 while field in current_table._inherit_fields and not field in current_table._columns:
46 parent_model_name = current_table._inherit_fields[field][0]
47 parent_table = self.pool.get(parent_model_name)
48- self._inherits_join_add(parent_model_name, query)
49+ current_table._inherits_join_add(parent_model_name, query)
50 current_table = parent_table
51 return '"%s".%s' % (current_table._table, field)
52
53@@ -2892,12 +2893,24 @@
54 for table in self._inherits:
55 res.update(self.pool.get(table)._inherit_fields)
56 for col in self.pool.get(table)._columns.keys():
57- res[col] = (table, self._inherits[table], self.pool.get(table)._columns[col])
58+ res[col] = (table, self._inherits[table], self.pool.get(table)._columns[col], table)
59 for col in self.pool.get(table)._inherit_fields.keys():
60- res[col] = (table, self._inherits[table], self.pool.get(table)._inherit_fields[col][2])
61+ res[col] = (table, self._inherits[table], self.pool.get(table)._inherit_fields[col][2], self.pool.get(table)._inherit_fields[col][3])
62 self._inherit_fields = res
63+ self._all_columns = self._get_column_infos()
64 self._inherits_reload_src()
65
66+ def _get_column_infos(self):
67+ """Returns a dict mapping all fields names (direct fields and
68+ inherited field via _inherits) to a ``column_info`` struct
69+ giving detailed columns """
70+ result = {}
71+ for k, (parent, m2o, col, original_parent) in self._inherit_fields.iteritems():
72+ result[k] = fields.column_info(k, col, parent, m2o, original_parent)
73+ for k, col in self._columns.iteritems():
74+ result[k] = fields.column_info(k, col)
75+ return result
76+
77 def _inherits_check(self):
78 for table, field_name in self._inherits.items():
79 if field_name not in self._columns:
80@@ -3589,7 +3602,7 @@
81 upd_todo = []
82 for v in vals.keys():
83 if v in self._inherit_fields:
84- (table, col, col_detail) = self._inherit_fields[v]
85+ (table, col, col_detail, original_parent) = self._inherit_fields[v]
86 tocreate[table][v] = vals[v]
87 del vals[v]
88 else:
89@@ -4000,7 +4013,7 @@
90 else:
91 continue # ignore non-readable or "non-joinable" fields
92 elif order_field in self._inherit_fields:
93- parent_obj = self.pool.get(self._inherit_fields[order_field][0])
94+ parent_obj = self.pool.get(self._inherit_fields[order_field][3])
95 order_column = parent_obj._columns[order_field]
96 if order_column._classic_read:
97 inner_clause = self._inherits_join_calc(order_field, query)
98@@ -4144,8 +4157,13 @@
99 for parent_column in ['parent_left', 'parent_right']:
100 data.pop(parent_column, None)
101
102- for v in self._inherits:
103- del data[self._inherits[v]]
104+ # remove _inherits field's from data recursively, missing parents will
105+ # be created by create() (so that copy() copy everything).
106+ def remove_ids(inherits_dict):
107+ for parent_table in inherits_dict:
108+ del data[inherits_dict[parent_table]]
109+ remove_ids(self.pool.get(parent_table)._inherits)
110+ remove_ids(self._inherits)
111 return data
112
113 def copy_translations(self, cr, uid, old_id, new_id, context=None):