← Back to team overview

openerp-dev-web team mailing list archive

[Merge] lp:~openerp-dev/openobject-server/trunk-bug-766944-ysa into lp:openobject-server

 

Yogesh(Open ERP) has proposed merging lp:~openerp-dev/openobject-server/trunk-bug-766944-ysa into lp:openobject-server.

Requested reviews:
  Naresh(OpenERP) (nch-openerp)
Related bugs:
  Bug #766944 in OpenERP Server: "6.0.2: Custom-Field in res_partner_addresscauses Error  with CRM-Module"
  https://bugs.launchpad.net/openobject-server/+bug/766944

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-bug-766944-ysa/+merge/61351

Add custom field in object then custom field not updated in inherit object. Custom filed is m2o and object is not depends on this module then continue execution field.
-- 
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-bug-766944-ysa/+merge/61351
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-server/trunk-bug-766944-ysa.
=== modified file 'openerp/addons/base/ir/ir_model.py'
--- openerp/addons/base/ir/ir_model.py	2011-04-11 10:13:27 +0000
+++ openerp/addons/base/ir/ir_model.py	2011-05-18 05:44:29 +0000
@@ -99,12 +99,12 @@
         'modules': fields.function(_in_modules, method=True, type='char', size=128, string='In modules', help='List of modules in which the object is defined or inherited'),
         'view_ids': fields.function(_view_ids, method=True, type='one2many', obj='ir.ui.view', string='Views'),
     }
-    
+
     _defaults = {
         'model': lambda *a: 'x_',
         'state': lambda self,cr,uid,ctx=None: (ctx and ctx.get('manual',False)) and 'manual' or 'base',
     }
-    
+
     def _check_model_name(self, cr, uid, ids, context=None):
         for model in self.browse(cr, uid, ids, context=context):
             if model.state=='manual':
@@ -285,7 +285,7 @@
                 self.pool.get(vals['model']).__init__(self.pool, cr)
                 #Added context to _auto_init for special treatment to custom field for select_level
                 ctx = context.copy()
-                ctx.update({'field_name':vals['name'],'field_state':'manual','select':vals.get('select_level','0'),'update_custom_fields':True})
+                ctx.update({'field_name':vals['name'],'field_state':'manual','select':vals.get('select_level','0')})
                 self.pool.get(vals['model'])._auto_init(cr, ctx)
 
         return res
@@ -388,7 +388,7 @@
             # Anything we don't update in _columns now will be reset from
             # the model into ir.model.fields (db).
             ctx = context.copy()
-            ctx.update({'select': vals.get('select_level','0'),'update_custom_fields':True})
+            ctx.update({'select': vals.get('select_level','0')})
 
             for model_key, patch_struct in models_patch.items():
                 obj = patch_struct[0]
@@ -497,8 +497,8 @@
             cr.execute('''select
                     g.name
                 from
-                    ir_model_access a 
-                    left join ir_model m on (a.model_id=m.id) 
+                    ir_model_access a
+                    left join ir_model m on (a.model_id=m.id)
                     left join res_groups g on (a.group_id=g.id)
                 where
                     m.model=%s and

=== modified file 'openerp/osv/orm.py'
--- openerp/osv/orm.py	2011-05-16 15:05:34 +0000
+++ openerp/osv/orm.py	2011-05-18 05:44:29 +0000
@@ -2432,7 +2432,6 @@
 
             # iterate on the "object columns"
             todo_update_store = []
-            update_custom_fields = context.get('update_custom_fields', False)
 
             cr.execute("SELECT c.relname,a.attname,a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,t.typname,CASE WHEN a.attlen=-1 THEN a.atttypmod-4 ELSE a.attlen END as size " \
                "FROM pg_class c,pg_attribute a,pg_type t " \
@@ -2445,9 +2444,6 @@
             for k in self._columns:
                 if k in ('id', 'write_uid', 'write_date', 'create_uid', 'create_date'):
                     continue
-                #Not Updating Custom fields
-                if k.startswith('x_') and not update_custom_fields:
-                    continue
 
                 f = self._columns[k]
 
@@ -2619,6 +2615,8 @@
                                 self.__schema.debug(msg, self._table, k, f._type)
 
                             if isinstance(f, fields.many2one):
+                                if not self.pool.get(f._obj):
+                                    continue
                                 ref = self.pool.get(f._obj)._table
                                 if ref != 'ir_actions':
                                     cr.execute('SELECT confdeltype, conname FROM pg_constraint as con, pg_class as cl1, pg_class as cl2, '


Follow ups