From 110483e93d4a6cf1f461002be93a607b4fb1ec65 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Wed, 8 Jun 2011 16:11:28 +0530 Subject: [PATCH 1/3] [FIX] fix problem of ir.property created if same value exists then record not create in ir.property object. lp bug: https://launchpad.net/bugs/726592 fixed bzr revid: ysa@tinyerp.com-20110608104128-7mdykmk0ovqenz6u --- openerp/osv/fields.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openerp/osv/fields.py b/openerp/osv/fields.py index 306e7d007f3..ec1845344ab 100644 --- a/openerp/osv/fields.py +++ b/openerp/osv/fields.py @@ -1047,7 +1047,14 @@ class property(function): default_val = self._get_default(obj, cr, uid, prop_name, context) - if id_val is not default_val: + property_create = False + if hasattr(default_val, '_id'): + if default_val._id != id_val: + property_create = True + elif id_val != default_val: + property_create = True + + if property_create: def_id = self._field_get(cr, uid, obj._name, prop_name) company = obj.pool.get('res.company') cid = company._company_default_get(cr, uid, obj._name, def_id, From 4de6b859796e6c18ce40f7776fd46437f376b33b Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Wed, 5 Oct 2011 12:21:55 +0530 Subject: [PATCH 2/3] [FIX] fix problem of poperty filed. if property field have a default value then check the id. bzr revid: ysa@tinyerp.com-20111005065155-nfwersyv05ddjq40 --- openerp/osv/fields.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openerp/osv/fields.py b/openerp/osv/fields.py index 47052d0797a..dc6a05b5925 100644 --- a/openerp/osv/fields.py +++ b/openerp/osv/fields.py @@ -525,7 +525,7 @@ class many2many(_column): _type = 'many2many' def __init__(self, obj, rel=None, id1=None, id2=None, string='unknown', limit=None, **args): - """ + """ """ _column.__init__(self, string=string, **args) self._obj = obj @@ -539,7 +539,7 @@ class many2many(_column): def _sql_names(self, source_model): """Return the SQL names defining the structure of the m2m relationship table - + :return: (m2m_table, local_col, dest_col) where m2m_table is the table name, local_col is the name of the column holding the current model's FK, and dest_col is the name of the column holding the destination model's FK, and @@ -1216,7 +1216,7 @@ class property(function): default_val = self._get_default(obj, cr, uid, prop_name, context) property_create = False - if hasattr(default_val, '_id'): + if hasattr(default_val, '_id') and default_val: if default_val._id != id_val: property_create = True elif id_val != default_val: From 491dc693d66ae45d2ddd22b0dbd1d6a554daa549 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Wed, 5 Oct 2011 17:48:57 +0200 Subject: [PATCH 3/3] [IMP] fields.property: be more explicit when testing if something is a browse_record. bzr revid: vmt@openerp.com-20111005154857-ic3yzb3dead33us3 --- openerp/osv/fields.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openerp/osv/fields.py b/openerp/osv/fields.py index dc6a05b5925..4e226f1c0ec 100644 --- a/openerp/osv/fields.py +++ b/openerp/osv/fields.py @@ -41,6 +41,7 @@ import warnings import xmlrpclib from psycopg2 import Binary +import openerp import openerp.netsvc as netsvc import openerp.tools as tools from openerp.tools.translate import _ @@ -1216,10 +1217,10 @@ class property(function): default_val = self._get_default(obj, cr, uid, prop_name, context) property_create = False - if hasattr(default_val, '_id') and default_val: - if default_val._id != id_val: + if isinstance(default_val, openerp.osv.orm.browse_record): + if default_val.id != id_val: property_create = True - elif id_val != default_val: + elif default_val != id_val: property_create = True if property_create: