GoodERP
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
2.2KB

  1. from odoo.tests.common import TransactionCase
  2. from odoo.exceptions import UserError
  3. class TestCommonDialogWizard(TransactionCase):
  4. def setUp(self):
  5. '''准备数据'''
  6. super(TestCommonDialogWizard, self).setUp()
  7. self.order = self.env.ref('sell.sell_order_2')
  8. self.order.sell_order_done()
  9. self.delivery = self.env['sell.delivery'].search(
  10. [('order_id', '=', self.order.id)])
  11. def test_do_confirm(self):
  12. '''弹窗确认按钮,正常情况'''
  13. vals = {}
  14. for line in self.delivery.line_out_ids:
  15. vals = {
  16. 'type': 'inventory',
  17. 'warehouse_id': self.env.ref('warehouse.warehouse_inventory').id,
  18. 'warehouse_dest_id': self.delivery.warehouse_id.id,
  19. 'line_in_ids': [(0, 0, {
  20. 'goods_id': line.goods_id.id,
  21. 'attribute_id': line.attribute_id.id,
  22. 'uos_id': line.uos_id.id,
  23. 'goods_qty': line.goods_qty,
  24. 'uom_id': line.uom_id.id,
  25. 'cost_unit': line.goods_id.cost
  26. }
  27. )]
  28. }
  29. wizard = self.env['common.dialog.wizard'].with_context({
  30. 'active_ids': self.delivery.id,
  31. 'active_model': 'sell.delivery',
  32. 'func': 'goods_inventory',
  33. 'args': [vals],
  34. }).create({})
  35. wizard.do_confirm()
  36. def test_do_confirm_no_func(self):
  37. '''弹窗确认按钮,不传func时应报错'''
  38. wizard = self.env['common.dialog.wizard'].with_context({
  39. 'active_ids': self.delivery.id,
  40. 'active_model': 'sell.delivery',
  41. 'func': '',
  42. }).create({})
  43. with self.assertRaises(ValueError):
  44. wizard.do_confirm()
  45. def test_do_confirm_no_active_ids(self):
  46. '''弹窗确认按钮,不传active_ids,active_model 时应报错'''
  47. wizard = self.env['common.dialog.wizard'].with_context({
  48. 'active_ids': False,
  49. 'active_model': '',
  50. 'func': 'goods_inventory',
  51. }).create({})
  52. with self.assertRaises(ValueError):
  53. wizard.do_confirm()
上海开阖软件有限公司 沪ICP备12045867号-1