Ignore:
Timestamp:
15 Mar 2015, 13:02:49 (10 years ago)
Author:
Henrik Bettermann
Message:

Add constraint to forbid the selection of options with different currencies.

File:
1 edited

Legend:

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

    r12741 r12768  
    3737
    3838
     39# Define a validation method for product options
     40class CurrencyMismatch(schema.ValidationError):
     41    __doc__ = u"Currency mismatch"
     42
     43
     44def unique_currency(value):
     45    currencies = set([x.currency for x in value])
     46    if len(currencies) > 1:
     47        raise CurrencyMismatch(value)
     48    return True
     49
     50
    3951class ICustomersUtils(Interface):
    4052    """A collection of methods which are subject to customization.
     
    324336            required = True,
    325337            ),
     338        constraint=unique_currency,
    326339        required = False,
    327340        readonly = False,
     
    379392    product_options = schema.List(
    380393        value_type = ProductOptionField(),
     394        constraint=unique_currency,
    381395        required = False,
    382396        readonly = False,
Note: See TracChangeset for help on using the changeset viewer.