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


Python exceptions.Warning方法代码示例

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


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

示例1: to_print

# 需要导入模块: from openerp import exceptions [as 别名]
# 或者: from openerp.exceptions import Warning [as 别名]
def to_print(recs):
        valid_input = re.match('^\s*\[?\s*((\d+)(\s*,\s*\d+)*)\s*\]?\s*$', recs[0].object_ids)
        valid_input = valid_input and valid_input.group(1) or False
        if not valid_input:
            raise Warning(_("Input single record ID or number of comma separated IDs!"))
        print_ids = eval("[%s]" % valid_input, {})
        rep_obj = recs.env['ir.actions.report.xml']
        report = rep_obj.browse(recs.env.context['active_ids'])[0]
        data = {
                'model': report.model,
                'ids': print_ids,
                'id': print_ids[0],
                'template': base64.b64decode(recs[0].template),
                'report_type': 'template_render'
                }
        res =  {
                'type': 'ir.actions.report.xml',
                'report_name': report.report_name,
                'datas': data,
                'context': recs.env.context
                }
        return res

    ### Fields 
开发者ID:vertelab,项目名称:odoo-report,代码行数:26,代码来源:report_test.py

示例2: to_print

# 需要导入模块: from openerp import exceptions [as 别名]
# 或者: from openerp.exceptions import Warning [as 别名]
def to_print(recs):
        valid_input = re.match('^\s*\[?\s*((\d+)(\s*,\s*\d+)*)\s*\]?\s*$', recs[0].object_ids)
        valid_input = valid_input and valid_input.group(1) or False
        if not valid_input:
            raise Warning(_("Input single record ID or number of comma separated IDs!"))
        print_ids = eval("[%s]" % valid_input, {})
        rep_obj = recs.env['ir.actions.report.xml']
        report = rep_obj.browse(recs.env.context['active_ids'])[0]
        data = {
                'model': report.model,
                'ids': print_ids,
                'id': print_ids[0],
                'template': base64.b64decode(recs[0].template) if recs[0].template else False,
                'report_type': 'scribus_sla'
                }
        res =  {
                'type': 'ir.actions.report.xml',
                'report_name': report.report_name,
                'datas': data,
                'context': recs.env.context
                }
        return res

    ### Fields 
开发者ID:vertelab,项目名称:odoo-report,代码行数:26,代码来源:report_test.py

示例3: to_print

# 需要导入模块: from openerp import exceptions [as 别名]
# 或者: from openerp.exceptions import Warning [as 别名]
def to_print(recs):
        valid_input = re.match('^\s*\[?\s*((\d+)(\s*,\s*\d+)*)\s*\]?\s*$', recs[0].object_ids)
        valid_input = valid_input and valid_input.group(1) or False
        if not valid_input:
            raise Warning(_("Input single record ID or number of comma separated IDs!"))
        print_ids = eval("[%s]" % valid_input, {})
        rep_obj = recs.env['ir.actions.report.xml']
        report = rep_obj.browse(recs.env.context['active_ids'])[0]
        data = {
                'model': report.model,
                'ids': print_ids,
                'id': print_ids[0],
                'template': recs[0].template,
                'report_type': 'glabels'
                }
        res =  {
                'type': 'ir.actions.report.xml',
                'report_name': report.report_name,
                'datas': data,
                'context': recs.env.context
                }
        return res

    ### Fields 
开发者ID:vertelab,项目名称:odoo-report,代码行数:26,代码来源:report_test.py

示例4: create

# 需要导入模块: from openerp import exceptions [as 别名]
# 或者: from openerp.exceptions import Warning [as 别名]
def create(self, cr, uid, vals, context=None):
        vote_id = super(Vote, self).create(cr, uid, vals, context=context)
        vote = self.browse(cr, uid, vote_id, context=context)

        # own post check
        if vote.user_id.id == vote.post_id.create_uid.id:
            raise Warning('Not allowed to vote for its own post')
        # karma check
        if vote.vote == '1' and not vote.post_id.can_upvote:
            raise KarmaError('Not enough karma to upvote.')
        elif vote.vote == '-1' and not vote.post_id.can_downvote:
            raise KarmaError('Not enough karma to downvote.')

        # karma update
        if vote.post_id.parent_id:
            karma_value = self._get_karma_value('0', vote.vote, vote.forum_id.karma_gen_answer_upvote, vote.forum_id.karma_gen_answer_downvote)
        else:
            karma_value = self._get_karma_value('0', vote.vote, vote.forum_id.karma_gen_question_upvote, vote.forum_id.karma_gen_question_downvote)
        self.pool['res.users'].add_karma(cr, SUPERUSER_ID, [vote.recipient_id.id], karma_value, context=context)
        return vote_id 
开发者ID:osbzr,项目名称:gooderp_org,代码行数:22,代码来源:forum.py

示例5: write

# 需要导入模块: from openerp import exceptions [as 别名]
# 或者: from openerp.exceptions import Warning [as 别名]
def write(self, cr, uid, ids, values, context=None):
        if 'vote' in values:
            for vote in self.browse(cr, uid, ids, context=context):
                # own post check
                if vote.user_id.id == vote.post_id.create_uid.id:
                    raise Warning('Not allowed to vote for its own post')
                # karma check
                if (values['vote'] == '1' or vote.vote == '-1' and values['vote'] == '0') and not vote.post_id.can_upvote:
                    raise KarmaError('Not enough karma to upvote.')
                elif (values['vote'] == '-1' or vote.vote == '1' and values['vote'] == '0') and not vote.post_id.can_downvote:
                    raise KarmaError('Not enough karma to downvote.')

                # karma update
                if vote.post_id.parent_id:
                    karma_value = self._get_karma_value(vote.vote, values['vote'], vote.forum_id.karma_gen_answer_upvote, vote.forum_id.karma_gen_answer_downvote)
                else:
                    karma_value = self._get_karma_value(vote.vote, values['vote'], vote.forum_id.karma_gen_question_upvote, vote.forum_id.karma_gen_question_downvote)
                self.pool['res.users'].add_karma(cr, SUPERUSER_ID, [vote.recipient_id.id], karma_value, context=context)
        res = super(Vote, self).write(cr, uid, ids, values, context=context)
        return res 
开发者ID:osbzr,项目名称:gooderp_org,代码行数:22,代码来源:forum.py

示例6: inject_company

# 需要导入模块: from openerp import exceptions [as 别名]
# 或者: from openerp.exceptions import Warning [as 别名]
def inject_company(self):
        company_obj = self.env['premium_company']
        if not self.partner_id and self.address_id:
            raise Warning('You can\'t give an address and no partner.\n\nAlways select a partner, then an address !')
        else:
            error_msg = company_obj._try_inject_company(self.env.context.get('active_id',False),self.partner_id.id,self.address_id and self.address_id.id or False,self.address_work_id and self.address_work_id.id or False,'wizard')
            if not error_msg or error_msg == 'Partner and Address Injected' or error_msg == 'Partner and Address Injected/Created':
                msg = 'Company fully injected'
            else:
                msg = 'Not injected.\n\nReason : %s' % error_msg
        
        ctx = self.env.context.copy()
        ctx.update({'msg':msg})
        return {
            'view_type': 'form',
            'view_mode': 'form',
            'res_model': 'inject.premium.company.msg',
            'view_id': False,
            'type': 'ir.actions.act_window',
            'target': 'new',
            'context': ctx,
        } 
开发者ID:philmervdm,项目名称:modules_cci_odoo8,代码行数:24,代码来源:inject_premium_company.py

示例7: check_group_type

# 需要导入模块: from openerp import exceptions [as 别名]
# 或者: from openerp.exceptions import Warning [as 别名]
def check_group_type(self):
        for grp in self:
            sql = '''
            select group_id from partner_zip_group_rel1 where zip_id=%d
            ''' % (grp.id)
            self.env.cr.execute(sql)
            groups = self.env.cr.fetchall()
        list_group = []
        for group in groups:
            list_group.append(group[0])
        data_zip = self.env['res.partner.zip.group'].browse(list_group)
        list_zip = []
        for data in data_zip:
            if data.type_id.id in list_zip:
                raise Warning(_('Error: Only one group of the same group type is allowed!'))
            list_zip.append(data.type_id.id)
        return True 
开发者ID:philmervdm,项目名称:modules_cci_odoo8,代码行数:19,代码来源:res_partner_zip.py

示例8: onchange_partner_id

# 需要导入模块: from openerp import exceptions [as 别名]
# 或者: from openerp.exceptions import Warning [as 别名]
def onchange_partner_id(self,part):
        warning = False
        if not part:
            return {'value':{}}
        part_obj = self.env['res.partner']
        data_partner = part_obj.browse(part)
        if data_partner.alert_legalisations:
                warning = {
                    'title': _("Warning:"),
                    'message': data_partner.alert_explanation or _('Partner is not valid')
                        }
#         addr = part_obj.address_get([part], ['contact'])
#         data = {'partner_address_id':addr['contact']}
        if warning:
            return {'warning': warning}
        return {'value':{}} 
开发者ID:philmervdm,项目名称:modules_cci_odoo8,代码行数:18,代码来源:cci_mission.py

示例9: icalendar_freebusy

# 需要导入模块: from openerp import exceptions [as 别名]
# 或者: from openerp.exceptions import Warning [as 别名]
def icalendar_freebusy(self, partner=False, **post):
        if partner:
            #~ raise Warning("Public successfull %s" % partner.get_ics_calendar(type='public').to_ical())
            #~ return partner.get_ics_calendar(type='public').to_ical()
            document = partner.sudo().get_ics_calendar(type='freebusy').to_ical()
            return request.make_response(
                document,
                headers=[
                    ('Content-Disposition', 'attachment; filename="freebusy.ifb"'),
                    ('Content-Type', 'text/calendar'),
                    ('Content-Length', len(document)),
                ]
            )
        else:
            raise Warning()
            pass # Some error page

#    @http.route(['/partner/<model("res.partner"):partner>/calendar/public.ics'], type='http', auth="public", website=True) 
开发者ID:vertelab,项目名称:odoo-calendar,代码行数:20,代码来源:res_partner.py

示例10: icalendar_public

# 需要导入模块: from openerp import exceptions [as 别名]
# 或者: from openerp.exceptions import Warning [as 别名]
def icalendar_public(self, partner=None, **post):
        if partner:
            #~ raise Warning("Public successfull %s" % partner.get_ics_calendar(type='public').to_ical())
            #~ return partner.sudo().get_ics_calendar(type='public')
            document = request.env['res.partner'].sudo().browse(partner).get_ics_calendar(type='public')
            return request.make_response(
                document,
                headers=[
                    ('Content-Disposition', 'attachment; filename="public.ics"'),
                    ('Content-Type', 'text/calendar'),
                    ('Content-Length', len(document)),
                ]
            )
        else:
            raise Warning("Public failed")
            pass # Some error page 
开发者ID:vertelab,项目名称:odoo-calendar,代码行数:18,代码来源:res_partner.py

示例11: _check_end_date

# 需要导入模块: from openerp import exceptions [as 别名]
# 或者: from openerp.exceptions import Warning [as 别名]
def _check_end_date(self):
        if self.end_date and self.end_date < self.start_date:            
            raise Warning(_("End Date should be grater than Start Date")) 
开发者ID:luigisison,项目名称:odoo-fhir,代码行数:5,代码来源:partner.py

示例12: _check_config_step

# 需要导入模块: from openerp import exceptions [as 别名]
# 或者: from openerp.exceptions import Warning [as 别名]
def _check_config_step(self):
        cfg_step_lines = self.product_tmpl_id.config_step_line_ids
        cfg_steps = cfg_step_lines.filtered(
            lambda l: l != self).mapped('config_step_id')
        if self.config_step_id in cfg_steps:
            raise Warning(_('Cannot have a configuration step defined twice.')) 
开发者ID:pledra,项目名称:odoo-product-configurator,代码行数:8,代码来源:product_config.py

示例13: onchange_product_tmpl

# 需要导入模块: from openerp import exceptions [as 别名]
# 或者: from openerp.exceptions import Warning [as 别名]
def onchange_product_tmpl(self):
        template = self.product_tmpl_id
        self.config_step_ids = template.config_step_line_ids.mapped(
            'config_step_id')
        if self.value_ids:
            # TODO: Add confirmation button an delete cfg session
            raise Warning(
                _('Changing the product template while having an active '
                  'configuration will erase reset/clear all values')
            ) 
开发者ID:pledra,项目名称:odoo-product-configurator,代码行数:12,代码来源:product_configurator.py

示例14: fields_view_get

# 需要导入模块: from openerp import exceptions [as 别名]
# 或者: from openerp.exceptions import Warning [as 别名]
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
        if self.env.context.get('active_id'):
            report = self.env['ir.actions.report.xml'].browse(self.env.context['active_ids'])
            if report.report_name == 'aeroo.printscreen.list':
                raise Warning(_("Print Screen report does not support this functionality!"))
        res = super(report_print_by_action, self).fields_view_get(view_id,
            view_type, toolbar=toolbar, submenu=submenu)
        return res 
开发者ID:vertelab,项目名称:odoo-report,代码行数:10,代码来源:report_test.py

示例15: _get_csv

# 需要导入模块: from openerp import exceptions [as 别名]
# 或者: from openerp.exceptions import Warning [as 别名]
def _get_csv(self):
        if not self.env.context.get('active_ids'):
            return None
        report = self.env['ir.actions.report.xml'].browse(self.env.context['active_ids'])[0]

        i = 1
        l = []
        for k in self.env[report.model].search([])[0].read()[0].keys():
            l.append('%s. %s' % (i,k))
            i += 1
        #~ raise Warning(self.env[model]._fields.keys())
        csv = ', '.join(l)
        return csv 
开发者ID:vertelab,项目名称:odoo-report,代码行数:15,代码来源:report_test.py


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