Merge lp:~openerp-dev/openobject-server/trunk-bug-823691-nch into lp:openobject-server

Proposed by Naresh(OpenERP)
Status: Merged
Merged at revision: 3627
Proposed branch: lp:~openerp-dev/openobject-server/trunk-bug-823691-nch
Merge into: lp:openobject-server
Diff against target: 145 lines (+27/-18)
2 files modified
openerp/osv/fields.py (+7/-3)
openerp/osv/orm.py (+20/-15)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/trunk-bug-823691-nch
Reviewer Review Type Date Requested Status
Vo Minh Thu Pending
Review via email: mp+73025@code.launchpad.net
To post a comment you must log in.
3551. By Vo Minh Thu

[MERGE] merged trunk.

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

The line 4056 in orm.py
            (table, col, col_detail) = self._inherit_fields[v]
should use a 4-tuple instead of a triple.

Naresh, don't fix it, I just need to not forget it when merging it. It seems good, thanks!

3552. By Naresh(OpenERP)

[FIX]:problem when coping the _inherits record the base class record was not created resulting the new record to refer the same parent that the old record is referring

3553. By Naresh(OpenERP)

[MERGE FROM TRUNK]

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openerp/osv/fields.py'
2--- openerp/osv/fields.py 2011-09-15 15:20:52 +0000
3+++ openerp/osv/fields.py 2011-09-19 09:35:28 +0000
4@@ -55,7 +55,7 @@
5
6 class _column(object):
7 """ Base of all fields, a database column
8-
9+
10 An instance of this object is a *description* of a database column. It will
11 not hold any data, but only provide the methods to manipulate data of an
12 ORM record or even prepare/update the database to hold such a field of data.
13@@ -1295,7 +1295,7 @@
14
15 def _fnct_read(self, obj, cr, uid, ids, prop_names, obj_dest, context=None):
16 prop = obj.pool.get('ir.property')
17- # get the default values (for res_id = False) for the property fields
18+ # get the default values (for res_id = False) for the property fields
19 default_val = self._get_defaults(obj, cr, uid, prop_names, context)
20
21 # build the dictionary that will be returned
22@@ -1417,12 +1417,16 @@
23 :attr parent_column: the name of the column containing the m2o
24 relationship to the parent model that contains
25 this column, None for local columns.
26+ :attr original_parent: if the column is inherited, name of the original
27+ parent model that contains it i.e in case of multilevel
28+ inheritence, None for local columns.
29 """
30- def __init__(self, name, column, parent_model=None, parent_column=None):
31+ def __init__(self, name, column, parent_model=None, parent_column=None, original_parent=None):
32 self.name = name
33 self.column = column
34 self.parent_model = parent_model
35 self.parent_column = parent_column
36+ self.original_parent = original_parent
37
38 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
39
40
41=== modified file 'openerp/osv/orm.py'
42--- openerp/osv/orm.py 2011-09-19 09:19:52 +0000
43+++ openerp/osv/orm.py 2011-09-19 09:35:28 +0000
44@@ -2666,20 +2666,22 @@
45 del d['id']
46 return data
47
48- def _inherits_join_add(self, parent_model_name, query):
49+ def _inherits_join_add(self, current_table, parent_model_name, query):
50 """
51 Add missing table SELECT and JOIN clause to ``query`` for reaching the parent table (no duplicates)
52-
53+ :param current_table: current model object
54 :param parent_model_name: name of the parent model for which the clauses should be added
55 :param query: query object on which the JOIN should be added
56 """
57- inherits_field = self._inherits[parent_model_name]
58+ inherits_field = current_table._inherits[parent_model_name]
59 parent_model = self.pool.get(parent_model_name)
60 parent_table_name = parent_model._table
61 quoted_parent_table_name = '"%s"' % parent_table_name
62 if quoted_parent_table_name not in query.tables:
63 query.tables.append(quoted_parent_table_name)
64- query.where_clause.append('("%s".%s = %s.id)' % (self._table, inherits_field, parent_table_name))
65+ query.where_clause.append('(%s.%s = %s.id)' % (current_table._table, inherits_field, parent_table_name))
66+
67+
68
69 def _inherits_join_calc(self, field, query):
70 """
71@@ -2694,7 +2696,7 @@
72 while field in current_table._inherit_fields and not field in current_table._columns:
73 parent_model_name = current_table._inherit_fields[field][0]
74 parent_table = self.pool.get(parent_model_name)
75- self._inherits_join_add(parent_model_name, query)
76+ self._inherits_join_add(current_table, parent_model_name, query)
77 current_table = parent_table
78 return '"%s".%s' % (current_table._table, field)
79
80@@ -3385,9 +3387,9 @@
81 for table in self._inherits:
82 other = self.pool.get(table)
83 for col in other._columns.keys():
84- res[col] = (table, self._inherits[table], other._columns[col])
85+ res[col] = (table, self._inherits[table], other._columns[col], table)
86 for col in other._inherit_fields.keys():
87- res[col] = (table, self._inherits[table], other._inherit_fields[col][2])
88+ res[col] = (table, self._inherits[table], other._inherit_fields[col][2], other._inherit_fields[col][3])
89 self._inherit_fields = res
90 self._all_columns = self._get_column_infos()
91 self._inherits_reload_src()
92@@ -3398,8 +3400,8 @@
93 inherited field via _inherits) to a ``column_info`` struct
94 giving detailed columns """
95 result = {}
96- for k, (parent, m2o, col) in self._inherit_fields.iteritems():
97- result[k] = fields.column_info(k, col, parent, m2o)
98+ for k, (parent, m2o, col, original_parent) in self._inherit_fields.iteritems():
99+ result[k] = fields.column_info(k, col, parent, m2o, original_parent)
100 for k, col in self._columns.iteritems():
101 result[k] = fields.column_info(k, col)
102 return result
103@@ -4108,7 +4110,7 @@
104 upd_todo = []
105 for v in vals.keys():
106 if v in self._inherit_fields:
107- (table, col, col_detail) = self._inherit_fields[v]
108+ (table, col, col_detail, original_parent) = self._inherit_fields[v]
109 tocreate[table][v] = vals[v]
110 del vals[v]
111 else:
112@@ -4438,7 +4440,7 @@
113 if parent_model and child_object:
114 # as inherited rules are being applied, we need to add the missing JOIN
115 # to reach the parent table (if it was not JOINed yet in the query)
116- child_object._inherits_join_add(parent_model, query)
117+ child_object._inherits_join_add(child_object, parent_model, query)
118 query.where_clause += added_clause
119 query.where_clause_params += added_params
120 for table in added_tables:
121@@ -4527,7 +4529,7 @@
122 else:
123 continue # ignore non-readable or "non-joinable" fields
124 elif order_field in self._inherit_fields:
125- parent_obj = self.pool.get(self._inherit_fields[order_field][0])
126+ parent_obj = self.pool.get(self._inherit_fields[order_field][3])
127 order_column = parent_obj._columns[order_field]
128 if order_column._classic_read:
129 inner_clause = self._inherits_join_calc(order_field, query)
130@@ -4671,9 +4673,12 @@
131 # force a clean recompute!
132 for parent_column in ['parent_left', 'parent_right']:
133 data.pop(parent_column, None)
134-
135- for v in self._inherits:
136- del data[self._inherits[v]]
137+ # remove _inherits field's from data recursively
138+ def remove_ids(inherits_dict):
139+ for parent_table in inherits_dict:
140+ del data[inherits_dict[parent_table]]
141+ remove_ids(self.pool.get(parent_table)._inherits)
142+ remove_ids(self._inherits)
143 return data
144
145 def copy_translations(self, cr, uid, old_id, new_id, context=None):