GoodERP
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

113 lines
4.8KB

  1. from odoo.tests.common import TransactionCase
  2. from odoo.exceptions import UserError
  3. class TestWarehouse(TransactionCase):
  4. def setUp(self):
  5. super(TestWarehouse, self).setUp()
  6. self.env.ref('core.goods_category_1').account_id = self.env.ref(
  7. 'finance.account_goods').id
  8. self.env.ref('warehouse.wh_in_whin0').date = '2016-02-06'
  9. self.hd_warehouse = self.browse_ref('warehouse.hd_stock')
  10. self.sh_warehouse = self.browse_ref('warehouse.sh_stock')
  11. self.internal = self.browse_ref('warehouse.wh_internal_whint0')
  12. self.overage_in = self.browse_ref('warehouse.wh_in_whin0')
  13. in_mouse_1 = self.env.ref('warehouse.wh_move_line_12')
  14. in_mouse_1.cost = in_mouse_1.cost_unit * in_mouse_1.goods_qty
  15. in_mouse_2 = self.env.ref('warehouse.wh_move_line_mouse_2')
  16. in_mouse_2.cost = in_mouse_2.cost_unit * in_mouse_2.goods_qty
  17. in_keyboard = self.env.ref('warehouse.wh_move_line_13')
  18. in_keyboard.cost = in_keyboard.cost_unit * in_keyboard.goods_qty
  19. in_cable = self.env.ref('warehouse.wh_move_line_14')
  20. in_cable.cost = in_cable.cost_unit * in_cable.goods_qty
  21. # 商品 仓库 数量 成本
  22. # 鼠标 总仓 2.0 80
  23. # 键盘 总仓 600.0 48000
  24. # 网线 总仓 11880.0 950400.0
  25. # 网线 上海 120.0 9600.0
  26. self.overage_in.approve_order()
  27. self.internal.approve_order()
  28. def test_name_search(self):
  29. # Stored labels may predate the Odoo18 compute fix. Recompute only
  30. # this transactional fixture, not installed business warehouses.
  31. self.hd_warehouse._compute_display_name()
  32. # 使用name来搜索总仓
  33. result = self.env['warehouse'].name_search('总仓')
  34. real_result = [(self.hd_warehouse.id, self.hd_warehouse.display_name)]
  35. self.assertIn(self.hd_warehouse.code, result[0][1])
  36. self.assertIn(self.hd_warehouse.name, result[0][1])
  37. self.assertEqual(result, real_result)
  38. # 使用code来搜索总仓
  39. result = self.env['warehouse'].name_search('000')
  40. self.assertEqual(result, real_result)
  41. with self.assertRaises(UserError):
  42. self.env['warehouse'].get_warehouse_by_type('error')
  43. # 临时在warehouse的类型中添加一个error类型的错误,让它跳过类型检测的异常
  44. # 此时在数据库中找不到该类型的仓库,应该报错
  45. x = self.env['warehouse'].search([('type', '=', 'inventory')])
  46. x.unlink()
  47. with self.assertRaises(UserError):
  48. self.env['warehouse'].get_warehouse_by_type('inventory')
  49. def test_scan_barcode(self):
  50. '''扫码出入库'''
  51. warehouse = self.env['wh.move']
  52. barcode = '12345678987'
  53. # 其它入库单扫码
  54. model_name = 'wh.in'
  55. order = self.env.ref('warehouse.wh_in_whin3')
  56. warehouse.scan_barcode(model_name, barcode, order.id)
  57. warehouse.scan_barcode(model_name, barcode, order.id)
  58. # 其他出库单扫码
  59. model_name = 'wh.out'
  60. order = self.env.ref('warehouse.wh_out_wh_out_attribute')
  61. warehouse.scan_barcode(model_name, barcode, order.id)
  62. warehouse.scan_barcode(model_name, barcode, order.id)
  63. # 调拔单的扫描条码
  64. model_name = 'wh.internal'
  65. order = self.env.ref('warehouse.wh_internal_whint0')
  66. warehouse.scan_barcode(model_name, barcode, order.id)
  67. # 能找到 barcode 对应的商品
  68. self.env.ref('warehouse.wh_move_line_17').goods_id = self.env.ref(
  69. 'goods.iphone').id
  70. warehouse.scan_barcode(model_name, barcode, order.id)
  71. # 盘点单的扫描条码
  72. model_name = 'wh.inventory'
  73. order = self.env.ref('warehouse.wh_inventory_0')
  74. warehouse.scan_barcode(model_name, barcode, order.id)
  75. warehouse.scan_barcode(model_name, barcode, order.id)
  76. # 商品不存在报错
  77. barcode = '12342312312'
  78. with self.assertRaises(UserError):
  79. warehouse.scan_barcode(model_name, barcode, order.id)
  80. # 商品的条形码扫码出入库
  81. barcode = '123456789'
  82. # 其它入库单扫码
  83. model_name = 'wh.in'
  84. order = self.env.ref('warehouse.wh_in_whin3')
  85. warehouse.scan_barcode(model_name, barcode, order.id)
  86. warehouse.scan_barcode(model_name, barcode, order.id)
  87. # 其他出库单扫码
  88. model_name = 'wh.out'
  89. order = self.env.ref('warehouse.wh_out_wh_out_attribute')
  90. warehouse.scan_barcode(model_name, barcode, order.id)
  91. warehouse.scan_barcode(model_name, barcode, order.id)
  92. def test_check_goods_qty(self):
  93. '''指定商品,属性,仓库,的当前剩余数量'''
  94. res = self.env['wh.move'].check_goods_qty(False, False, self.hd_warehouse)[0]
  95. self.assertTrue(not res)
上海开阖软件有限公司 沪ICP备12045867号-1