Merge lp:~openerp-dev/openobject-server/trunk-bug-726592-ysa into lp:openobject-server

Proposed by Yogesh (SerpentCS)
Status: Merged
Merged at revision: 3734
Proposed branch: lp:~openerp-dev/openobject-server/trunk-bug-726592-ysa
Merge into: lp:openobject-server
Diff against target: 45 lines (+11/-3)
1 file modified
openerp/osv/fields.py (+11/-3)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/trunk-bug-726592-ysa
Reviewer Review Type Date Requested Status
Yogesh (SerpentCS) (community) Needs Resubmitting
Vo Minh Thu (community) Needs Fixing
Naresh(OpenERP) (community) Approve
Review via email: mp+63844@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

hello

can you please create a separate merge proposal for 6.0 too because this bug affects it

Thanks

Revision history for this message
Naresh(OpenERP) (nch-openerp) :
review: Approve
Revision history for this message
Vo Minh Thu (thu) wrote :

The line
  if hasattr(default_val, '_id'):
seems to assume that
  self._get_default()
could return a browse record. But I don't think this is the case.

review: Needs Fixing
3451. By Yogesh (SerpentCS)

[MERGE] Merge wtih trunk server upto revision no 3722.

3452. By Yogesh (SerpentCS)

[FIX] fix problem of poperty filed. if property field have a default value then check the id.

Revision history for this message
Yogesh (SerpentCS) (yogesh-serpentcs) wrote :

Hello Sir,

I checked this issue. I found problem in if id_val is not default_val: condition. if property field type is m2o then this condition always true and new record create in ir.property object. if field type is m2o then self._get_default() return the browse record so id_val is simple int id and default_val is browse record so never match the default record. so in this situation check the default_val have _id attribute if yes then check and fetch id of that field like defult_val._id and check this with id_val if not match then create record of property object. if field type is not m2o then check simple condition like :- id_val != default_val.

If I missing some thing then correct me.

Thanks,

review: Needs Resubmitting
3453. By Vo Minh Thu

[IMP] fields.property: be more explicit when testing if something is a browse_record.

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-10-05 13:55:49 +0000
3+++ openerp/osv/fields.py 2011-10-05 15:53:25 +0000
4@@ -41,6 +41,7 @@
5 import xmlrpclib
6 from psycopg2 import Binary
7
8+import openerp
9 import openerp.netsvc as netsvc
10 import openerp.tools as tools
11 from openerp.tools.translate import _
12@@ -537,7 +538,7 @@
13 _type = 'many2many'
14
15 def __init__(self, obj, rel=None, id1=None, id2=None, string='unknown', limit=None, **args):
16- """
17+ """
18 """
19 _column.__init__(self, string=string, **args)
20 self._obj = obj
21@@ -551,7 +552,7 @@
22
23 def _sql_names(self, source_model):
24 """Return the SQL names defining the structure of the m2m relationship table
25-
26+
27 :return: (m2m_table, local_col, dest_col) where m2m_table is the table name,
28 local_col is the name of the column holding the current model's FK, and
29 dest_col is the name of the column holding the destination model's FK, and
30@@ -1227,7 +1228,14 @@
31
32 default_val = self._get_default(obj, cr, uid, prop_name, context)
33
34- if id_val is not default_val:
35+ property_create = False
36+ if isinstance(default_val, openerp.osv.orm.browse_record):
37+ if default_val.id != id_val:
38+ property_create = True
39+ elif default_val != id_val:
40+ property_create = True
41+
42+ if property_create:
43 def_id = self._field_get(cr, uid, obj._name, prop_name)
44 company = obj.pool.get('res.company')
45 cid = company._company_default_get(cr, uid, obj._name, def_id,