GoodERP
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

66 lines
2.4KB

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