[IMP] xmlrpc/exceptions: added a model and a view to exercise exception handling.
bzr revid: vmt@openerp.com-20110930093755-ee6569l3bhgrervp
This commit is contained in:
parent
f82c6503b7
commit
d273e72f35
|
@ -0,0 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import models
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,15 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
{
|
||||
'name': 'test-exceptions',
|
||||
'version': '0.1',
|
||||
'category': 'Tests',
|
||||
'description': """A module to generate exceptions.""",
|
||||
'author': 'OpenERP SA',
|
||||
'maintainer': 'OpenERP SA',
|
||||
'website': 'http://www.openerp.com',
|
||||
'depends': ['base'],
|
||||
'data': ['view.xml'],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
}
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,33 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import openerp
|
||||
|
||||
class m(openerp.osv.osv.Model):
|
||||
""" This model exposes a few methods that will raise the different
|
||||
exceptions that must be handled by the server (and its RPC layer)
|
||||
and the clients.
|
||||
"""
|
||||
_name = 'test.exceptions.model'
|
||||
|
||||
def generate_except_osv(self, cr, uid, ids, context=None):
|
||||
# title is ignored in the new (6.1) exceptions
|
||||
raise openerp.osv.osv.except_osv('title', 'description')
|
||||
|
||||
def generate_except_orm(self, cr, uid, ids, context=None):
|
||||
# title is ignored in the new (6.1) exceptions
|
||||
raise openerp.osv.orm.except_orm('title', 'description')
|
||||
|
||||
def generate_warning(self, cr, uid, ids, context=None):
|
||||
raise openerp.exceptions.Warning('description')
|
||||
|
||||
def generate_access_denied(self, cr, uid, ids, context=None):
|
||||
raise openerp.exceptions.AccessDenied()
|
||||
|
||||
def generate_access_error(self, cr, uid, ids, context=None):
|
||||
raise openerp.exceptions.AccessError('description')
|
||||
|
||||
def generate_exc_access_denied(self, cr, uid, ids, context=None):
|
||||
raise Exception('AccessDenied')
|
||||
|
||||
def generate_undefined(self, cr, uid, ids, context=None):
|
||||
self.surely_undefined_sumbol
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,68 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_test_exceptions_model" model="ir.ui.view">
|
||||
<field name="name">Test exceptions</field>
|
||||
<field name="model">test.exceptions.model</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Test exceptions">
|
||||
<label string="Each button generates a specific exception on the server. The text on the right is the expected representation of the exception when displayed on the client."/>
|
||||
<group colspan="8" col="8">
|
||||
<separator string="" colspan="8"/>
|
||||
<button name="generate_except_osv" string="except_osv" type="object" icon="gtk-ok" colspan="1"/>
|
||||
<label string="Warning-description"/>
|
||||
</group>
|
||||
<group colspan="8" col="8">
|
||||
<button name="generate_except_orm" string="except_orm" type="object" icon="gtk-ok" colspan="1"/>
|
||||
<label string="Warning-description"/>
|
||||
</group>
|
||||
<group colspan="8" col="8">
|
||||
<button name="generate_warning" string="Warning" type="object" icon="gtk-ok" colspan="1"/>
|
||||
<label string="Warning-description"/>
|
||||
</group>
|
||||
<group colspan="8" col="8">
|
||||
<button name="generate_access_denied" string="AccessDenied" type="object" icon="gtk-ok" colspan="1"/>
|
||||
<label string="Access denied-traceback"/>
|
||||
</group>
|
||||
<group colspan="8" col="8">
|
||||
<button name="generate_access_error" string="AccessError" type="object" icon="gtk-ok" colspan="1"/>
|
||||
<label string="Access rights error-description"/>
|
||||
</group>
|
||||
<group colspan="8" col="8">
|
||||
<button name="generate_exc_access_denied" string="Exc AccessDenied" type="object" icon="gtk-ok" colspan="1"/>
|
||||
<label string="Access denied-traceback"/>
|
||||
</group>
|
||||
<group colspan="8" col="8">
|
||||
<button name="generate_undefined" string="Undefined" type="object" icon="gtk-ok" colspan="1"/>
|
||||
<label string="Server error-traceback"/>
|
||||
</group>
|
||||
<group colspan="8" col="8">
|
||||
<separator string="" colspan="8"/>
|
||||
<label colspan="6" width="220"/>
|
||||
<button special="cancel" string="Cancel" icon="gtk-cancel" colspan="1"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_test_exceptions" model="ir.actions.act_window">
|
||||
<field name="name">Test exceptions</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">test.exceptions.model</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<menuitem icon="STOCK_PREFERENCES" id="base.menu_tests" name="Tests"/>
|
||||
|
||||
<menuitem id="menu_test_exceptions" parent="base.menu_tests" name="Test exceptions"/>
|
||||
|
||||
<menuitem id="menu_test_exceptions_leaf"
|
||||
name="Test exceptions"
|
||||
action="action_test_exceptions"
|
||||
parent="menu_test_exceptions"/>
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue