當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。