On Wed, Jul 26, 2006 at 06:33:50PM +0200, Carlo Cardelli wrote:
> class IInvoice(Interface):
>     invRef = Int(
>         title=u"Ref.no",
>         description=u"Invoice reference number",
>         min=1,
>         required=True
>         )
>     invDate = Date(
>         title=u"Date",
>         description=u"Invoice Date",
>         required=True
>         )
>     invCust = Object(
>         schema=ICustomer,
>         title=u"Customer",
>         description=u"Customer",
>         required=True
>         )
>     ... other ininfluent fields...
> 
> 
> Now, I have to render the 'invCust' object as a selection-list showing 
> the custNames of all possible Customers, where the user can select the 
> appropriate Customer for the Invoice. Editing the Invoice, the 
> selection-list should position itself showing the Customer set previously.
> In other words, I need a widget that somewhat behave like 
> "Plone.Archetypes.ReferenceWidget".
> I know that this is a very basic problem. Anyone already implemented it?

What you need to do is define the customer field as a choice in the interface:

    class IInvoice(Interface):
        ...
        invCust = Choice(title=u"Customer",
                         vocabulary="Customers")

and define the "Customers" vocabulary, that will list all customers in
your app.  Look at zope.schema.vocabulary.SimpleVocabulary.

Albertas
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to