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
=== modified file 'bin/osv/fields.py'
--- bin/osv/fields.py 2011-12-15 10:08:55 +0000
+++ bin/osv/fields.py 2012-03-14 11:34:19 +0000
@@ -1123,5 +1123,27 @@
1123 self.field_id = {}1123 self.field_id = {}
11241124
11251125
1126class column_info(object):
1127 """Struct containing details about an osv column, either one local to
1128 its model, or one inherited via _inherits.
1129
1130 :attr name: name of the column
1131 :attr column: column instance, subclass of osv.fields._column
1132 :attr parent_model: if the column is inherited, name of the model
1133 that contains it, None for local columns.
1134 :attr parent_column: the name of the column containing the m2o
1135 relationship to the parent model that contains
1136 this column, None for local columns.
1137 :attr original_parent: if the column is inherited, name of the original
1138 parent model that contains it i.e in case of multilevel
1139 inheritence, None for local columns.
1140 """
1141 def __init__(self, name, column, parent_model=None, parent_column=None, original_parent=None):
1142 self.name = name
1143 self.column = column
1144 self.parent_model = parent_model
1145 self.parent_column = parent_column
1146 self.original_parent = original_parent
1147
1126# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:1148# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
11271149
11281150
=== modified file 'bin/osv/orm.py'
--- bin/osv/orm.py 2012-03-09 07:45:27 +0000
+++ bin/osv/orm.py 2012-03-14 11:34:19 +0000
@@ -2140,6 +2140,7 @@
2140class orm(orm_template):2140class orm(orm_template):
2141 _sql_constraints = []2141 _sql_constraints = []
2142 _table = None2142 _table = None
2143 _all_columns = {}
2143 _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']2144 _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']
2144 __logger = logging.getLogger('orm')2145 __logger = logging.getLogger('orm')
2145 __schema = logging.getLogger('orm.schema')2146 __schema = logging.getLogger('orm.schema')
@@ -2293,7 +2294,7 @@
2293 while field in current_table._inherit_fields and not field in current_table._columns:2294 while field in current_table._inherit_fields and not field in current_table._columns:
2294 parent_model_name = current_table._inherit_fields[field][0]2295 parent_model_name = current_table._inherit_fields[field][0]
2295 parent_table = self.pool.get(parent_model_name)2296 parent_table = self.pool.get(parent_model_name)
2296 self._inherits_join_add(parent_model_name, query)2297 current_table._inherits_join_add(parent_model_name, query)
2297 current_table = parent_table2298 current_table = parent_table
2298 return '"%s".%s' % (current_table._table, field)2299 return '"%s".%s' % (current_table._table, field)
22992300
@@ -2892,12 +2893,24 @@
2892 for table in self._inherits:2893 for table in self._inherits:
2893 res.update(self.pool.get(table)._inherit_fields)2894 res.update(self.pool.get(table)._inherit_fields)
2894 for col in self.pool.get(table)._columns.keys():2895 for col in self.pool.get(table)._columns.keys():
2895 res[col] = (table, self._inherits[table], self.pool.get(table)._columns[col])2896 res[col] = (table, self._inherits[table], self.pool.get(table)._columns[col], table)
2896 for col in self.pool.get(table)._inherit_fields.keys():2897 for col in self.pool.get(table)._inherit_fields.keys():
2897 res[col] = (table, self._inherits[table], self.pool.get(table)._inherit_fields[col][2])2898 res[col] = (table, self._inherits[table], self.pool.get(table)._inherit_fields[col][2], self.pool.get(table)._inherit_fields[col][3])
2898 self._inherit_fields = res2899 self._inherit_fields = res
2900 self._all_columns = self._get_column_infos()
2899 self._inherits_reload_src()2901 self._inherits_reload_src()
29002902
2903 def _get_column_infos(self):
2904 """Returns a dict mapping all fields names (direct fields and
2905 inherited field via _inherits) to a ``column_info`` struct
2906 giving detailed columns """
2907 result = {}
2908 for k, (parent, m2o, col, original_parent) in self._inherit_fields.iteritems():
2909 result[k] = fields.column_info(k, col, parent, m2o, original_parent)
2910 for k, col in self._columns.iteritems():
2911 result[k] = fields.column_info(k, col)
2912 return result
2913
2901 def _inherits_check(self):2914 def _inherits_check(self):
2902 for table, field_name in self._inherits.items():2915 for table, field_name in self._inherits.items():
2903 if field_name not in self._columns:2916 if field_name not in self._columns:
@@ -3589,7 +3602,7 @@
3589 upd_todo = []3602 upd_todo = []
3590 for v in vals.keys():3603 for v in vals.keys():
3591 if v in self._inherit_fields:3604 if v in self._inherit_fields:
3592 (table, col, col_detail) = self._inherit_fields[v]3605 (table, col, col_detail, original_parent) = self._inherit_fields[v]
3593 tocreate[table][v] = vals[v]3606 tocreate[table][v] = vals[v]
3594 del vals[v]3607 del vals[v]
3595 else:3608 else:
@@ -4000,7 +4013,7 @@
4000 else:4013 else:
4001 continue # ignore non-readable or "non-joinable" fields4014 continue # ignore non-readable or "non-joinable" fields
4002 elif order_field in self._inherit_fields:4015 elif order_field in self._inherit_fields:
4003 parent_obj = self.pool.get(self._inherit_fields[order_field][0])4016 parent_obj = self.pool.get(self._inherit_fields[order_field][3])
4004 order_column = parent_obj._columns[order_field]4017 order_column = parent_obj._columns[order_field]
4005 if order_column._classic_read:4018 if order_column._classic_read:
4006 inner_clause = self._inherits_join_calc(order_field, query)4019 inner_clause = self._inherits_join_calc(order_field, query)
@@ -4144,8 +4157,13 @@
4144 for parent_column in ['parent_left', 'parent_right']:4157 for parent_column in ['parent_left', 'parent_right']:
4145 data.pop(parent_column, None)4158 data.pop(parent_column, None)
41464159
4147 for v in self._inherits:4160 # remove _inherits field's from data recursively, missing parents will
4148 del data[self._inherits[v]]4161 # be created by create() (so that copy() copy everything).
4162 def remove_ids(inherits_dict):
4163 for parent_table in inherits_dict:
4164 del data[inherits_dict[parent_table]]
4165 remove_ids(self.pool.get(parent_table)._inherits)
4166 remove_ids(self._inherits)
4149 return data4167 return data
41504168
4151 def copy_translations(self, cr, uid, old_id, new_id, context=None):4169 def copy_translations(self, cr, uid, old_id, new_id, context=None):