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
=== modified file 'openerp/osv/fields.py'
--- openerp/osv/fields.py 2011-10-05 13:55:49 +0000
+++ openerp/osv/fields.py 2011-10-05 15:53:25 +0000
@@ -41,6 +41,7 @@
41import xmlrpclib41import xmlrpclib
42from psycopg2 import Binary42from psycopg2 import Binary
4343
44import openerp
44import openerp.netsvc as netsvc45import openerp.netsvc as netsvc
45import openerp.tools as tools46import openerp.tools as tools
46from openerp.tools.translate import _47from openerp.tools.translate import _
@@ -537,7 +538,7 @@
537 _type = 'many2many'538 _type = 'many2many'
538539
539 def __init__(self, obj, rel=None, id1=None, id2=None, string='unknown', limit=None, **args):540 def __init__(self, obj, rel=None, id1=None, id2=None, string='unknown', limit=None, **args):
540 """ 541 """
541 """542 """
542 _column.__init__(self, string=string, **args)543 _column.__init__(self, string=string, **args)
543 self._obj = obj544 self._obj = obj
@@ -551,7 +552,7 @@
551552
552 def _sql_names(self, source_model):553 def _sql_names(self, source_model):
553 """Return the SQL names defining the structure of the m2m relationship table554 """Return the SQL names defining the structure of the m2m relationship table
554 555
555 :return: (m2m_table, local_col, dest_col) where m2m_table is the table name,556 :return: (m2m_table, local_col, dest_col) where m2m_table is the table name,
556 local_col is the name of the column holding the current model's FK, and557 local_col is the name of the column holding the current model's FK, and
557 dest_col is the name of the column holding the destination model's FK, and558 dest_col is the name of the column holding the destination model's FK, and
@@ -1227,7 +1228,14 @@
12271228
1228 default_val = self._get_default(obj, cr, uid, prop_name, context)1229 default_val = self._get_default(obj, cr, uid, prop_name, context)
12291230
1230 if id_val is not default_val:1231 property_create = False
1232 if isinstance(default_val, openerp.osv.orm.browse_record):
1233 if default_val.id != id_val:
1234 property_create = True
1235 elif default_val != id_val:
1236 property_create = True
1237
1238 if property_create:
1231 def_id = self._field_get(cr, uid, obj._name, prop_name)1239 def_id = self._field_get(cr, uid, obj._name, prop_name)
1232 company = obj.pool.get('res.company')1240 company = obj.pool.get('res.company')
1233 cid = company._company_default_get(cr, uid, obj._name, def_id,1241 cid = company._company_default_get(cr, uid, obj._name, def_id,