Buenas a todos,
Soy nuevo en web2py y en este foro, gracias por recibirme.
Estoy diseñando un proyecto e intentando hacer un controlador genérico. Me encuentro con el problema de que la propiedad linked_tables del FORM.smartgrid me está generando links duplicados a las tablas dependientes, en algunos casos colocando una vez el campo en minúscula y la segunda, con mayúsculas.
La db es:
db.define_table('h_banco',
Field('ID_PERSONA','reference persona'),
Field('FECHA_INICIO',type = 'date', length = 6),
Field('FECHA_FIN',type = 'date', length = 6),
Field('ID_BANCO','reference banco'),
Field('SUCURSAL',type = 'string', length = 20),
Field('TIPO_CUENTA',type = 'string', length = 2),
Field('CUENTA',type = 'string', length = 20),
Field('CBU',type = 'string', length = 22),
Field('ID_FORMA_PAGO','reference forma_pago'),
Field('NOTAS',type = 'string', length = 255),
Field('ID_USUARIO',type = 'string', length = 40, default=auth.user_id, update=auth.user_id, readable=False, writeable=False),
Field('FECHA_GRABADO',type = 'datetime', default=request.now,update=request.now,writable=False, readable=False),
migrate = True, redefine=True)
db.h_banco.ID_PERSONA.requires = IS_IN_DB(db,
db.persona.id, '%(APELLIDO)s, %(NOMBRES)s')
db.h_banco.ID_BANCO.requires = IS_IN_DB(db,
db.banco.id, '%(BANCO)s')
db.h_banco.ID_FORMA_PAGO.requires = IS_IN_DB(db,
db.forma_pago.id, '%(FORMA_PAGO)s')
db.define_table('persona',
Field('ID_EMPRESA','reference empresa'),
Field('ID_PERSONA',type = 'string', length = 10),
Field('APELLIDO',type = 'string', length = 50),
Field('NOMBRES',type = 'string', length = 60),
Field('ID_TIPO_DOCUMENTO','reference tipos_documento'),
Field('NUMERO_DOCUMENTO',type = 'bigint', length = 20),
Field('CUIL',type = 'string', length = 13),
Field('FECHA_NACIMIENTO',type = 'date', length = 6),
Field('NACIONALIDAD',type = 'string', length = 20),
Field('ID_ESTADO_CIVIL','reference tipos_estado_civil'),
Field('FECHA_CASAMIENTO',type = 'date', length = 6),
Field('SEXO',type = 'string', length = 1),
Field('DOMICILIO_CALLE',type = 'string', length = 50),
Field('DOMICILIO_NUMERO',type = 'string', length = 20),
Field('TELEFONO',type = 'string', length = 20),
Field('E_MAIL',type = 'string', length = 255),
Field('NOTAS',type = 'string', length = 255),
Field('ID_USUARIO',type = 'string', length = 40, default=auth.user_id, update=auth.user_id, readable=False, writeable=False),
Field('FECHA_GRABADO',type = 'datetime', default=request.now,update=request.now,writable=False, readable=False),
migrate = True, redefine=True)
La llamada al smartgrid es URL('default','grid',args=['persona','h_banco'])
y en default.py:
def grid():
response.view = 'generic1.html' # use a generic view
tablename = request.args(0)
if not tablename in db.tables: raise HTTP(403)
response.title = tablename.capitalize()
children = []
for x in request.args:
if x<>request.args(0) and x in db.tables:
children.append(x)
grid = SQLFORM.smartgrid(db[tablename], args=[tablename], linked_tables=children, create=True,deletable=True, editable=True, buttons_placement = 'left', links_placement = 'left', showbuttontext=True, ui='web2py')
return dict(grid=grid)
Desde ya les agradezco si tienen alguna idea de cómo solucionarlo.
Saludos!
Esteban