GoodERP
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

84 líneas
3.1KB

  1. from odoo.tests.common import TransactionCase
  2. from odoo.exceptions import UserError
  3. class TestLocation(TransactionCase):
  4. def setUp(self):
  5. ''' 准备基本数据 '''
  6. super(TestLocation, self).setUp()
  7. self.location = self.env.ref('warehouse.a001_location')
  8. def test_change_location(self):
  9. ''' 测试商品库位转移 按钮 '''
  10. self.assertEqual(self.location.current_qty, 0)
  11. self.location.change_location()
  12. class TestChangeLocation(TransactionCase):
  13. def setUp(self):
  14. ''' 准备基本数据 '''
  15. super(TestChangeLocation, self).setUp()
  16. self.location = self.env.ref('warehouse.a001_location')
  17. self.others_wh_in = self.env.ref('warehouse.wh_in_whin0')
  18. self.env.ref(
  19. 'warehouse.wh_move_line_14').location_id = self.location.id
  20. # 填充库位数量
  21. self.others_wh_in.approve_order()
  22. # location: a0001; goods: cable; qty: 12000
  23. self.location_b001 = self.env.ref('warehouse.b001_location')
  24. self.change_loc = self.env['change.location'].create({
  25. 'from_location': self.location.id,
  26. 'to_location': self.location_b001.id,
  27. 'change_qty': 1,
  28. })
  29. ''' odoo13 必须在这里read一下后面sql才能取到数据 '''
  30. for l in self.env['wh.move.line'].search([]):
  31. l.read()
  32. def test_confirm_change(self):
  33. ''' 测试商品库位转移 '''
  34. self.location_b001.goods_id = self.env.ref('goods.cable').id
  35. self.change_loc.confirm_change()
  36. ''' odoo13 必须在这里read一下后面sql才能取到数据 '''
  37. for l in self.env['wh.move.line'].search([]):
  38. l.read()
  39. #self.assertEqual(self.location.current_qty, 11999)
  40. self.assertEqual(self.location_b001.current_qty, 1)
  41. # 报错:请检查转出库位与转入库位的产品、产品属性是否都相同!
  42. self.location_b001.goods_id = self.env.ref('goods.mouse').id
  43. with self.assertRaises(UserError):
  44. self.change_loc.confirm_change()
  45. # 报错:转出数量不能小于零
  46. self.change_loc.change_qty = -1
  47. with self.assertRaises(UserError):
  48. self.change_loc.confirm_change()
  49. # 报错:转出数量不能等于零
  50. self.change_loc.change_qty = 0.0
  51. with self.assertRaises(UserError):
  52. self.change_loc.confirm_change()
  53. # 报错:转出库位 与转入库位不能相同
  54. self.change_loc.change_qty = 1
  55. self.change_loc.to_location = self.location.id
  56. with self.assertRaises(UserError):
  57. self.change_loc.confirm_change()
  58. # 报错:转出数量不能大于库位现有数量
  59. self.change_loc.change_qty = 12000
  60. self.change_loc.to_location = self.location_b001.id
  61. with self.assertRaises(UserError):
  62. self.change_loc.confirm_change()
  63. def test_wh_move_approve_order(self):
  64. '''每次移库完成,清空库位上商品数量为0的商品和属性'''
  65. # 从库位a001到库位b001转存12000
  66. self.change_loc.change_qty = 12000
  67. self.change_loc.confirm_change()
上海开阖软件有限公司 沪ICP备12045867号-1