product_attribute.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:odoo-product-configurator 作者: pledra 项目源码 文件源码
def validate_custom_val(self, val):
        """ Pass in a desired custom value and ensure it is valid.
        Probaly should check type, etc, but let's assume fine for the moment.
        """
        self.ensure_one()
        if self.custom_type in ('int', 'float'):
            minv = self.min_val
            maxv = self.max_val
            val = literal_eval(val)
            if minv and maxv and (val < minv or val > maxv):
                raise ValidationError(
                    _("Selected custom value '%s' must be between %s and %s"
                        % (self.name, self.min_val, self.max_val))
                )
            elif minv and val < minv:
                raise ValidationError(
                    _("Selected custom value '%s' must be at least %s" %
                        (self.name, self.min_val))
                )
            elif maxv and val > maxv:
                raise ValidationError(
                    _("Selected custom value '%s' must be lower than %s" %
                        (self.name, self.max_val + 1))
                )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号