def validate(self, value):
     super(ValidateSKUUniqueness, self).validate(value)
     if getattr(self.context, 'sku', u'') != value:
         catalog = getToolByName(self.context, 'portal_catalog')
         brains = catalog({
             'sku': value,
         })
         if brains:
             raise Invalid(_(u'The SKU is already in use.'))
    def validate(self, value):
        super(ValidateSKUUniqueness, self).validate(value)

        if getattr(self.context, 'sku', u'') != value:
            adapter = IAdapter(self.context)
            brains = adapter.get_brains(IArticle, path=adapter.portal_path(), sku=value)

            if brains:
                raise Invalid(_(u'The SKU is already in use.'))
 def validate(self, value):
     super(ValidateSKUUniqueness, self).validate(value)
     if getattr(self.context, 'sku', u'') != value:
         catalog = getToolByName(self.context, 'portal_catalog')
         brains = catalog({
             'sku': value,
         })
         if brains:
             raise Invalid(_(u'The SKU is already in use.'))
예제 #4
0
class SKUSchema(Schema):
    """Schema for behavior: SKU"""

    sku = schema.TextLine(
        title=_(u"SKU"),
        description=_(u"Unique ID for Stock Keeping Unit."))