Advertisement
Guest User

Untitled

a guest
Nov 4th, 2015
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. ## Ejemplo 1
  2. class mi_clase(osv.Model):
  3.  
  4.     _name = 'tabla.objeto'
  5.    
  6.     def _get_name_rel(self, cr, uid, ids, fields_name, args, context=None):
  7.         res = {}
  8.         for i in self.browse(cr, uid, ids, context):
  9.             res[i.id] = ''
  10.             if i.res_user:
  11.                  res[i.id] = i.res_user.name
  12.         return res
  13.  
  14.    _columns = {
  15.        'usuario': fields.function(_get_name_rel, type='char', string='Usuario', store=True)
  16.    }
  17.  
  18.  
  19. # Ejemplo 2
  20. class mi_clase(osv.Model):
  21.  
  22.     _name = 'tabla.objeto'
  23.    
  24.     def _get_name_rel(self, cr, uid, context=None):
  25.         res = {}
  26.         res = 'Nombre'
  27.         return res
  28.  
  29.    _columns = {
  30.        'usuario': fields.char('Usuario', size=2048)
  31.    }
  32.    _defaults = {
  33.         'usuario': _get_name_rel
  34.    }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement