当前位置: 首页>>代码示例>>Python>>正文


Python exceptions.ValidationError方法代码示例

本文整理汇总了Python中odoo.exceptions.ValidationError方法的典型用法代码示例。如果您正苦于以下问题:Python exceptions.ValidationError方法的具体用法?Python exceptions.ValidationError怎么用?Python exceptions.ValidationError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在odoo.exceptions的用法示例。


在下文中一共展示了exceptions.ValidationError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: do_mass_update

# 需要导入模块: from odoo import exceptions [as 别名]
# 或者: from odoo.exceptions import ValidationError [as 别名]
def do_mass_update(self):
        self.ensure_one()
        if not (self.new_deadline or self.new_user_id):
            raise exceptions.ValidationError('No data to update!')
        # Logging debug messages
        _logger.debug(
            'Mass update on Todo Tasks %s',
            self.task_ids.ids)
        vals = {}
        if self.new_deadline:
            vals['date_deadline'] = self.new_deadline
        if self.new_user_id:
            vals['user_id'] = self.new_user_id
        # Mass write values on all selected tasks
        if vals:
            self.task_ids.write(vals)
        return True 
开发者ID:PacktPublishing,项目名称:Odoo-11-Development-Essentials-Third-Edition,代码行数:19,代码来源:todo_wizard_model.py

示例2: write

# 需要导入模块: from odoo import exceptions [as 别名]
# 或者: from odoo.exceptions import ValidationError [as 别名]
def write(self, vals):
        try:
            for each_record in self:
                if 'sort' in vals.keys() and vals.get('sort') != each_record.sort:
                    each_record._write(vals)
                    goods_ids = self.env['wechat_mall.goods'].with_context({'recompute': True}).browse(
                        each_record._goods_ids())
                    if goods_ids:
                        for goods_id in goods_ids:
                            goods_id.write({'price_ids': [(6, 0, goods_id._price_ids().ids)]})
                else:
                    each_record._write(vals)

        except Exception as e:
            raise exceptions.ValidationError(e)
        else:
            return True 
开发者ID:elfgzp,项目名称:wechat_mall,代码行数:19,代码来源:goods.py

示例3: update_batch

# 需要导入模块: from odoo import exceptions [as 别名]
# 或者: from odoo.exceptions import ValidationError [as 别名]
def update_batch(self):
        self.ensure_one()
        if not (self.new_is_closed or self.wizard_user_id):
            raise exceptions.ValidationError('无数据要更新')
        _logger.debug('批量bug更新操作 %s',self.bug_ids.ids)
        vals={}
        if self.new_is_closed:
            vals['is_closed']=self.new_is_closed
        if self.wizard_user_id:
            vals['user_id']=self.wizard_user_id
        if vals:
            self.bug_ids.write(vals)
        return True 
开发者ID:ScottAI,项目名称:Odoo-Python-ERP-,代码行数:15,代码来源:bug_wizard.py

示例4: website_form_input_filter

# 需要导入模块: from odoo import exceptions [as 别名]
# 或者: from odoo.exceptions import ValidationError [as 别名]
def website_form_input_filter(self, request, values):
        if values.get('name'):
            # Modify values
            values['name'] = values['name'].strip()
            # Validate values
            if len(values['name']) < 3:
                raise ValidationError(
                    '名称长度不可以少于3个字符')
        return values 
开发者ID:ScottAI,项目名称:Odoo-Python-ERP-,代码行数:11,代码来源:bug.py

示例5: _constrain_isbn_valid

# 需要导入模块: from odoo import exceptions [as 别名]
# 或者: from odoo.exceptions import ValidationError [as 别名]
def _constrain_isbn_valid(self):
        for book in self:
            if book.isbn and not book._check_isbn():
                raise ValidationError(
                    '%s is an invalid ISBN' % book.isbn) 
开发者ID:PacktPublishing,项目名称:Odoo-12-Development-Essentials-Fourth-Edition,代码行数:7,代码来源:library_book.py

示例6: generate_token

# 需要导入模块: from odoo import exceptions [as 别名]
# 或者: from odoo.exceptions import ValidationError [as 别名]
def generate_token(self):
        config = self.env['wxxcx.config']
        secret_key = config.get_config('secret', self.create_uid.id)
        app_id = config.get_config('app_id', self.create_uid.id)
        if not secret_key or not app_id:
            raise exceptions.ValidationError('未设置 secret_key 或 appId')

        s = Serializer(secret_key=secret_key, salt=app_id, expires_in=AccessToken._transient_max_hours * 3600)
        timestamp = time.time()
        return s.dumps({'session_key': self.session_key, 'open_id': self.open_id, 'iat': timestamp}) 
开发者ID:ScottAI,项目名称:-Odoo---,代码行数:12,代码来源:wxxcx_access_token.py

示例7: check_dates

# 需要导入模块: from odoo import exceptions [as 别名]
# 或者: from odoo.exceptions import ValidationError [as 别名]
def check_dates(self):
        for record in self:
            start_date = fields.Date.from_string(record.start_date)
            end_date = fields.Date.from_string(record.end_date)
            if start_date > end_date:
                raise ValidationError(_("End Date cannot be set before \
                Start Date.")) 
开发者ID:ScottAI,项目名称:-Odoo---,代码行数:9,代码来源:schedule.py

示例8: check_subject

# 需要导入模块: from odoo import exceptions [as 别名]
# 或者: from odoo.exceptions import ValidationError [as 别名]
def check_subject(self):
    # 检查科目是否属于课程
       if(self.subject_id not in self.schedule_id.course_id.subject_ids):
           raise ValidationError(('''科目%s不属于课程计划%s''')%(self.subject_id.name,
                                                       self.schedule_id.name)) 
开发者ID:ScottAI,项目名称:-Odoo---,代码行数:7,代码来源:schedule.py

示例9: check_teacher

# 需要导入模块: from odoo import exceptions [as 别名]
# 或者: from odoo.exceptions import ValidationError [as 别名]
def check_teacher(self):
        #检查教师是否可以进行对应科目的授课
        if(self.subject_id not in self.teacher_id.teacher_subject_ids):
            raise ValidationError(('''教师%s不可以进行科目%s的授课''')%(self.teacher_id.name,
                                                            self.subject_id.name)) 
开发者ID:ScottAI,项目名称:-Odoo---,代码行数:7,代码来源:schedule.py

示例10: _check_date_time

# 需要导入模块: from odoo import exceptions [as 别名]
# 或者: from odoo.exceptions import ValidationError [as 别名]
def _check_date_time(self):
        if self.start_datetime > self.end_datetime:
            raise ValidationError(_(
                'End Time cannot be set before Start Time.')) 
开发者ID:ScottAI,项目名称:-Odoo---,代码行数:6,代码来源:schedule.py

示例11: _check_birthdate

# 需要导入模块: from odoo import exceptions [as 别名]
# 或者: from odoo.exceptions import ValidationError [as 别名]
def _check_birthdate(self):
        for record in self:
            if record.birth_date > fields.Date.today():
                raise ValidationError(_(
                    "出生日期不可以晚于今天!")) 
开发者ID:ScottAI,项目名称:-Odoo---,代码行数:7,代码来源:teacher.py

示例12: check_dates

# 需要导入模块: from odoo import exceptions [as 别名]
# 或者: from odoo.exceptions import ValidationError [as 别名]
def check_dates(self):
        start_date = fields.Date.from_string(self.start_date)
        end_date = fields.Date.from_string(self.end_date)
        if start_date > end_date:
            raise ValidationError(_("End Date cannot be set before \
            Start Date.")) 
开发者ID:ScottAI,项目名称:-Odoo---,代码行数:8,代码来源:generate_timetable.py

示例13: do_mass_update

# 需要导入模块: from odoo import exceptions [as 别名]
# 或者: from odoo.exceptions import ValidationError [as 别名]
def do_mass_update(self):
        self.ensure_one()
        if not self.new_deadline and not self.new_user_id:
            raise exceptions.ValidationError('No data to update!')
        _logger.debug('Mass update on Todo Tasks %s' % self.task_ids)
        # Values to Write
        vals = {}
        if self.new_deadline:
            vals['date_deadline'] = self.new_deadline
        if self.new_user_id:
            vals['user_id'] = self.new_user_id
        # Mass write values on all selected tasks
        if vals:
            self.task_ids.write(vals)
        return True 
开发者ID:PacktPublishing,项目名称:Odoo-10-Development-Essentials,代码行数:17,代码来源:todo_wizard_model.py

示例14: do_toggle_done

# 需要导入模块: from odoo import exceptions [as 别名]
# 或者: from odoo.exceptions import ValidationError [as 别名]
def do_toggle_done(self):
        for task in self:
            if task.user_id != self.env.user:
                raise ValidationError(
                    'Only the responsible can do this!')
        return super(TodoTask, self).do_toggle_done() 
开发者ID:PacktPublishing,项目名称:Odoo-10-Development-Essentials,代码行数:8,代码来源:todo_task.py

示例15: _check_name_size

# 需要导入模块: from odoo import exceptions [as 别名]
# 或者: from odoo.exceptions import ValidationError [as 别名]
def _check_name_size(self):
        for todo in self:
            if len(todo.name) < 5:
                raise ValidationError('Title must have 5 chars!')

    # Chapter 06 Smart Button statistic 
开发者ID:PacktPublishing,项目名称:Odoo-10-Development-Essentials,代码行数:8,代码来源:todo_model.py


注:本文中的odoo.exceptions.ValidationError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。