GoodERP
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

49 rindas
1.8KB

  1. # Copyright 2016 上海开阖软件有限公司 (http://www.osbzr.com)
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo.tests.common import TransactionCase
  4. class TestCommonDialogWizard(TransactionCase):
  5. def setUp(self):
  6. '''准备数据'''
  7. super(TestCommonDialogWizard, self).setUp()
  8. # 公司对应的联系人记录
  9. self.partner = self.env.ref('base.main_partner')
  10. def test_do_confirm(self):
  11. '''弹窗确认按钮,正常情况'''
  12. new_mobile = '13333333333'
  13. self.assertNotEqual(self.partner.mobile, new_mobile)
  14. self.partner.open_dialog('write',
  15. {'args': [{'mobile': new_mobile}]})
  16. wizard = self.env['common.dialog.wizard'].with_context({
  17. 'active_ids': self.partner.id,
  18. 'active_model': self.partner._name,
  19. 'func': 'write',
  20. 'args': [{'mobile': new_mobile}],
  21. }).create({})
  22. wizard.do_confirm()
  23. self.assertEqual(self.partner.mobile, new_mobile)
  24. def test_do_confirm_no_func(self):
  25. '''弹窗确认按钮,不传func时应报错'''
  26. wizard = self.env['common.dialog.wizard'].with_context({
  27. 'active_ids': self.partner.id,
  28. 'active_model': self.partner._name,
  29. 'func': '',
  30. }).create({})
  31. with self.assertRaises(ValueError):
  32. wizard.do_confirm()
  33. def test_do_confirm_no_active_ids(self):
  34. '''弹窗确认按钮,不传active_ids,active_model 时应报错'''
  35. wizard = self.env['common.dialog.wizard'].with_context({
  36. 'active_ids': False,
  37. 'active_model': '',
  38. 'func': 'write',
  39. }).create({})
  40. with self.assertRaises(ValueError):
  41. wizard.do_confirm()
上海开阖软件有限公司 沪ICP备12045867号-1