本文整理匯總了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
示例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
示例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
示例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
示例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
示例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,
}
示例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
示例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':{}}
示例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)
示例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
示例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"))
示例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.'))
示例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')
)
示例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
示例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