Ignore:
Timestamp:
26 Dec 2014, 09:35:21 (10 years ago)
Author:
Henrik Bettermann
Message:

Add product_options field.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba/customers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/interfaces.py

    r12289 r12324  
    3030from waeup.ikoba.customers.vocabularies import (
    3131    contextual_reg_num_source, GenderSource, nats_vocab,
    32     ConCatProductSource, CustomerDocumentSource)
     32    ConCatProductSource, CustomerDocumentSource,
     33    ProductOptionSource)
    3334
    3435
     
    310311        )
    311312
     313    product_options = schema.List(
     314        title = _(u'Options/Fees'),
     315        value_type = schema.Choice(
     316            source=ProductOptionSource(),
     317            required = True,
     318            ),
     319        required = False,
     320        readonly = False,
     321        default = [],
     322        )
     323
    312324
    313325class IContractEdit(IContract):
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/vocabularies.py

    r12127 r12324  
    160160    def getTitle(self, context, value):
    161161        return "%s - %s" % (value.document_id, value.title)
     162
     163class ProductOptionSource(BasicContextualSourceFactory):
     164    """A product option source delivers all options belonging to
     165    a selected product.
     166    """
     167
     168    def getValues(self, context):
     169        product = getattr(context, 'product_object', None)
     170        if product is None:
     171            return []
     172        return product.options
     173
     174    def getToken(self, context, value):
     175        return value.title
     176
     177    def getTitle(self, context, value):
     178        return "%s @ %s %s" % (value.title, value.fee, value.currency)
Note: See TracChangeset for help on using the changeset viewer.