[Erp5-dev] Relation String Field - using something other than title

Jérome Perrin jerome at nexedi.com
Thu Aug 9 10:18:22 CEST 2007


Łukasz Nowak a écrit :
> Hello,
> 
> I've got two types: A and B. I want to relate A -> B by category
> 'category'.
> 
> So for type A I've created form which has RelationStringField:
> 
> my_category_title
> 
> Configured as said on wiki[1].
> 
> All works fine. But my type B has also shu_prop property, which is
> catalogued. So I created another RelationStringField for A type with:
> 
> my_category_shu_prop
> 
> And set 'Catalog Index' to shu_prop.
> 
> Almost all works great:
>  * my newly created field sets relation between A and B
>  * I'm able to narrow searching in shu_prop field by typing some parts
> of shu_prop property
>  * even my_category_title is updated (because it is reading from
> object the relating category, isn't it? (or smth similar))
> 
> Only thing, which do not work, is that on my_category_shu_prop no text
> is shown and so no jump field is available, etc.
> 
> How my I gain such behaviour? Shall I patch ERP5Type/Utils.py and
> ERP5Type/Accessors/Value.py and create there getter/setter for ShuProp?

Hello,

Yes, a way is to generate category accessors for getCategoryShuProp, but 
an easiest way is to use something like 'python: 
context.getCategoryValue().getShuProp()' in the 'default' TALES of your 
relation field.

( you can add a condition to handle the case where 
context.getCategoryValue() is None )

Jérome



More information about the Erp5-dev mailing list