Have you tried computed fields? As far as I have understood your question, 
it will be nicer :)
http://web2py.com/books/default/chapter/29/06#Computed-fields

On Tuesday, 9 July 2013 00:49:52 UTC+2, greenpoise wrote:
>
> I changed the logic of my tables and sort of got it working:
>
> db.define_table('supplier',
>     Field('suppliercode'),
>     Field('suppliername'))
> db.supplier.suppliercode.requires = IS_NOT_IN_DB(db,db.supplier.
> suppliercode)
> db.supplier.suppliername.requires = IS_NOT_IN_DB(db,db.supplier.
> suppliername)
>   
>
>
> db.define_table('series',
>     Field('supplier','reference supplier'),
>     Field('suppcode',represent=lambda id, r: '%s %s' % (r.series.
> suppliercode, r.product.tilename)),
>     Field('seriesname'),
>     Field('seriesdescription'),
>     Field('description')...
>         
> db.define_table('product',
>     Field('series', 'reference series'),
>     Field('description',represent=lambda id, r: '%s %s' % (r.series.
> seriesname, r.series.id))
>
>
> Now the problem is that suppcode shows me the id of supplier as opposed of 
> my suppliercode.
>
>
>
>
>
>
> On Monday, July 8, 2013 3:19:30 PM UTC-7, greenpoise wrote:
>>
>> db.define_table('supplier',
>>     Field('suppliercode'),
>>     Field('suppliername'))
>> db.supplier.suppliercode.requires = 
>> IS_NOT_IN_DB(db,db.supplier.suppliercode)
>> db.supplier.suppliername.requires = 
>> IS_NOT_IN_DB(db,db.supplier.suppliername)
>>   
>>
>> db.define_table('series',
>>     Field('supplier','reference supplier'),
>>     Field('seriesname'),
>>     Field('seriesdescription'),
>>     Field('description')...
>>         
>> db.define_table('product',
>>     Field('series', 'reference series'),
>>     Field('suppcode',represent=lambda id, r: '%s %s' % 
>> (r.series.suppliercode, r.product.tilename)),
>>     Field('description',represent=lambda id, r: '%s %s' % 
>> (r.series.seriesname, r.series.id))
>>
>>
>> In the code above, the second represent works while the second does not. 
>> What am I missing?? thanks!!!
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to