[IMP]base/res :set photo when create company from childs
authorBhumika (OpenERP) <sbh@tinyerp.com>
Tue, 13 Mar 2012 06:13:38 +0000 (11:43 +0530)
committerBhumika (OpenERP) <sbh@tinyerp.com>
Tue, 13 Mar 2012 06:13:38 +0000 (11:43 +0530)
bzr revid: sbh@tinyerp.com-20120313061338-dh2i2ve0rhbl1jha

openerp/addons/base/res/res_partner.py

index a6b93b8..ba16173 100644 (file)
@@ -259,13 +259,15 @@ class res_partner(osv.osv):
         return super(res_partner,self).write(cr, uid, ids, vals, context=context)
 
     def create(self, cr, uid, vals, context=None):
+        if context is None:
+            context={}
         # Update parent and siblings records
         if vals.get('parent_id') and vals.get('use_parent_address'):
             domain_siblings = [('parent_id', '=', vals['parent_id']), ('use_parent_address', '=', True)]
             update_ids = [vals['parent_id']] + self.search(cr, uid, domain_siblings, context=context)
             self.update_address(cr, uid, update_ids, vals, context)
-        if 'photo' not in vals:
-            vals['photo'] = self._get_photo(cr, uid, vals.get('is_company', False), context)
+        if 'photo' not in vals  :
+            vals['photo'] = self._get_photo(cr, uid, vals.get('is_company', False) or context.get('default_is_company'), context)
         return super(res_partner,self).create(cr, uid, vals, context=context)
 
     def update_address(self, cr, uid, ids, vals, context=None):