[MERGE]:trunk
bzr revid: apa@tinyerp.com-20121030090709-wep2fvyqlqckei9c
This commit is contained in:
commit
62111b4316
|
@ -132,20 +132,29 @@ class ir_ui_menu(osv.osv):
|
|||
return len(result)
|
||||
return result
|
||||
|
||||
def _get_full_name(self, cr, uid, ids, name, args, context):
|
||||
res = {}
|
||||
for m in self.browse(cr, uid, ids, context=context):
|
||||
res[m.id] = self._get_one_full_name(m)
|
||||
def name_get(self, cr, uid, ids, context=None):
|
||||
res = []
|
||||
for id in ids:
|
||||
elmt = self.browse(cr, uid, id, context=context)
|
||||
res.append((id, self._get_one_full_name(elmt)))
|
||||
return res
|
||||
|
||||
def _get_one_full_name(self, menu, level=6):
|
||||
def _get_full_name(self, cr, uid, ids, name=None, args=None, context=None):
|
||||
if context == None:
|
||||
context = {}
|
||||
res = {}
|
||||
for elmt in self.browse(cr, uid, ids, context=context):
|
||||
res[elmt.id] = self._get_one_full_name(elmt)
|
||||
return res
|
||||
|
||||
def _get_one_full_name(self, elmt, level=6):
|
||||
if level<=0:
|
||||
return '...'
|
||||
if menu.parent_id:
|
||||
parent_path = self._get_one_full_name(menu.parent_id, level-1) + "/"
|
||||
if elmt.parent_id:
|
||||
parent_path = self._get_one_full_name(elmt.parent_id, level-1) + "/"
|
||||
else:
|
||||
parent_path = ''
|
||||
return parent_path + menu.name
|
||||
return parent_path + elmt.name
|
||||
|
||||
def create(self, *args, **kwargs):
|
||||
self.clear_cache()
|
||||
|
@ -282,7 +291,7 @@ class ir_ui_menu(osv.osv):
|
|||
'groups_id': fields.many2many('res.groups', 'ir_ui_menu_group_rel',
|
||||
'menu_id', 'gid', 'Groups', help="If you have groups, the visibility of this menu will be based on these groups. "\
|
||||
"If this field is empty, OpenERP will compute visibility based on the related object's read access."),
|
||||
'complete_name': fields.function(_get_full_name,
|
||||
'complete_name': fields.function(_get_full_name,
|
||||
string='Full Path', type='char', size=128),
|
||||
'icon': fields.selection(tools.icons, 'Icon', size=64),
|
||||
'icon_pict': fields.function(_get_icon_pict, type='char', size=32),
|
||||
|
|
|
@ -105,7 +105,7 @@
|
|||
<field name="name">ir.module.module.form</field>
|
||||
<field name="model">ir.module.module</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Module" version="7.0">
|
||||
<form create="0" edit="0" string="Module" version="7.0">
|
||||
<sheet>
|
||||
<field name="icon_image" widget="image" class="oe_avatar oe_left"/>
|
||||
<div class="oe_title">
|
||||
|
|
|
@ -9,6 +9,7 @@ See the :ref:`test-framework` section in the :ref:`features` list.
|
|||
"""
|
||||
|
||||
from . import test_expression, test_html_sanitize, test_ir_sequence, test_orm,\
|
||||
test_per_class_teardown, \
|
||||
test_view_validation, test_uninstall, test_misc, test_db_cursor
|
||||
|
||||
fast_suite = [
|
||||
|
@ -20,6 +21,7 @@ checks = [
|
|||
test_html_sanitize,
|
||||
test_db_cursor,
|
||||
test_orm,
|
||||
test_per_class_teardown,
|
||||
test_view_validation,
|
||||
test_misc,
|
||||
]
|
||||
|
|
|
@ -40,10 +40,25 @@ def stop_openerp():
|
|||
"""
|
||||
openerp.service.stop_services()
|
||||
|
||||
class TransactionCase(unittest2.TestCase):
|
||||
|
||||
class BaseCase(unittest2.TestCase):
|
||||
"""
|
||||
Subclass of TestCase with a single transaction, rolled-back at the end of
|
||||
the tests.
|
||||
Subclass of TestCase for common OpenERP-specific code.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def cursor(self):
|
||||
return openerp.modules.registry.RegistryManager.get(DB).db.cursor()
|
||||
|
||||
@classmethod
|
||||
def registry(self, model):
|
||||
return openerp.modules.registry.RegistryManager.get(DB)[model]
|
||||
|
||||
|
||||
class TransactionCase(BaseCase):
|
||||
"""
|
||||
Subclass of BaseCase with a single transaction, rolled-back at the end of
|
||||
each test (method).
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
|
@ -54,11 +69,23 @@ class TransactionCase(unittest2.TestCase):
|
|||
self.cr.rollback()
|
||||
self.cr.close()
|
||||
|
||||
def cursor(self):
|
||||
return openerp.modules.registry.RegistryManager.get(DB).db.cursor()
|
||||
|
||||
def registry(self, model):
|
||||
return openerp.modules.registry.RegistryManager.get(DB)[model]
|
||||
class SingleTransactionCase(BaseCase):
|
||||
"""
|
||||
Subclass of BaseCase with a single transaction for the whole class,
|
||||
rolled-back after all the tests.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.cr = cls.cursor()
|
||||
cls.uid = openerp.SUPERUSER_ID
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.cr.rollback()
|
||||
cls.cr.close()
|
||||
|
||||
|
||||
class RpcCase(unittest2.TestCase):
|
||||
"""
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import unittest2
|
||||
|
||||
import openerp
|
||||
import common
|
||||
|
||||
class test_per_class_teardown(common.SingleTransactionCase):
|
||||
"""
|
||||
Check the whole-class transaction behavior of SingleTransactionCase.
|
||||
"""
|
||||
|
||||
def test_00(self):
|
||||
"""Create a partner."""
|
||||
cr, uid = self.cr, self.uid
|
||||
self.registry('res.partner').create(cr, uid, {'name': 'test_per_class_teardown_partner'})
|
||||
ids = self.registry('res.partner').search(cr, uid, [('name', '=', 'test_per_class_teardown_partner')])
|
||||
self.assertEqual(1, len(ids), "Test partner not found.")
|
||||
|
||||
def test_01(self):
|
||||
"""Find the created partner."""
|
||||
cr, uid = self.cr, self.uid
|
||||
ids = self.registry('res.partner').search(cr, uid, [('name', '=', 'test_per_class_teardown_partner')])
|
||||
self.assertEqual(1, len(ids), "Test partner not found.")
|
||||
|
||||
class test_per_method_teardown(common.TransactionCase):
|
||||
"""
|
||||
Check the per-method transaction behavior of TransactionCase.
|
||||
"""
|
||||
|
||||
def test_00(self):
|
||||
"""Create a partner."""
|
||||
cr, uid = self.cr, self.uid
|
||||
ids = self.registry('res.partner').search(cr, uid, [('name', '=', 'test_per_class_teardown_partner')])
|
||||
self.assertEqual(0, len(ids), "Test partner found.")
|
||||
self.registry('res.partner').create(cr, uid, {'name': 'test_per_class_teardown_partner'})
|
||||
ids = self.registry('res.partner').search(cr, uid, [('name', '=', 'test_per_class_teardown_partner')])
|
||||
self.assertEqual(1, len(ids), "Test partner not found.")
|
||||
|
||||
def test_01(self):
|
||||
"""Don't find the created partner."""
|
||||
cr, uid = self.cr, self.uid
|
||||
ids = self.registry('res.partner').search(cr, uid, [('name', '=', 'test_per_class_teardown_partner')])
|
||||
self.assertEqual(0, len(ids), "Test partner found.")
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest2.main()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
Loading…
Reference in New Issue