Problems with the reference fields in the tables

3

I have these tables:

db.define_table('marcas_definiciones',
                Field('marca', 'string', label=T('Marca GG')),
                Field('razon_zocial_gg', 'reference razones_zociales_gg'),
                Field('ruc', 'string', label=T('RUC GG')),
                format='%(marca)s')


db.define_table('cuentas_por_cobrar_y_pagar',
                Field('marca', 'reference marcas_definiciones'),
                Field('saldo_total_cobrar', 'float'),
                Field('saldo_total_pagar', 'float'),
                format='%(marca)s')


db.define_table('cobranzas',
                Field('marca', 'reference cuentas_por_cobrar_y_pagar'),
                Field('numero_comprobante', 'string'),
                Field('nota', 'text'),
                format='%(prefijo_comprobante)s %(numero_comprobante)s')

This is the driver:

def cuentas_por_cobrar_y_pagar():
    response.view = 'finances/default.html'
    form = SQLFORM.smartgrid(db.cuentas_por_cobrar_y_pagar, linked_tables=[
        'cobranzas',
        'pagos'
    ])
    return dict(form=form,page_name="Cuentas por cobrar")

Where cuentas_por_cobrar_y_pagar has a field that is marcas_definiciones and table cobranzas is a subtable of cuentas_por_cobrar_y_pagar unique by the field marca , the problem is that when I want to select the marca in the cobranzas table, this appears as the ID number but from the marca_definicion table and not one of the marks in the cuentas_por_cobrar_y_pagar table.

How can I solve it?

    
asked by Fernando M. Goycochea 02.01.2016 в 17:25
source

1 answer

2

Since you are using a reference to display the record, you can try using lambda in the format in table cuentas_por_cobrar_y_pagar :

db.define_table('cuentas_por_cobrar_y_pagar',
    Field('marca', 'reference marcas_definiciones'),
    Field('saldo_total_cobrar', 'float'),
    Field('saldo_total_pagar', 'float'),
    format=lambda r: r.marca.marca
)

This ensures the call to the field marca of the table marcas_definiciones which is a string .

    
answered by 02.01.2016 / 19:50
source