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.

70 lines
3.2KB

  1. from odoo.tests.common import TransactionCase
  2. from odoo.exceptions import UserError
  3. import time
  4. class TestQcRule(TransactionCase):
  5. ''' 测试和仓库相关的商品的有关逻辑 '''
  6. def setUp(self):
  7. super(TestQcRule, self).setUp()
  8. # 入库类型单据
  9. self.rule_buy = self.env['qc.rule'].create({
  10. 'move_type': 'buy.receipt.buy'})
  11. self.rule_sell_return = self.env['qc.rule'].create({
  12. 'move_type': 'sell.delivery.return'})
  13. self.rule_wh_in = self.env['qc.rule'].create({
  14. 'move_type': 'wh.in.others'})
  15. self.rule_wh_in_inv = self.env['qc.rule'].create({
  16. 'move_type': 'wh.in.inventory'})
  17. # 出库类型单据
  18. self.rule_sell = self.env['qc.rule'].create({
  19. 'move_type': 'sell.delivery.sell'})
  20. self.rule_buy_return = self.env['qc.rule'].create({
  21. 'move_type': 'buy.receipt.return'})
  22. self.rule_wh_out = self.env['qc.rule'].create({
  23. 'move_type': 'wh.out.others'})
  24. self.rule_wh_out_inv = self.env['qc.rule'].create({
  25. 'move_type': 'wh.out.inventory'})
  26. self.warehouse_supplier = self.env.ref('warehouse.warehouse_supplier')
  27. self.warehouse_customer = self.env.ref('warehouse.warehouse_customer')
  28. self.warehouse_others = self.env.ref('warehouse.warehouse_others')
  29. self.warehouse_inventory = self.env.ref(
  30. 'warehouse.warehouse_inventory')
  31. def test_compute_warehouse_impl(self):
  32. ''' 根据单据类型自动填充上调出仓库 '''
  33. self.rule_wh_in.onchange_move_type()
  34. self.assertTrue(self.rule_wh_in.warehouse_id == self.warehouse_others)
  35. self.rule_wh_in_inv.onchange_move_type()
  36. self.assertTrue(self.rule_wh_in_inv.warehouse_id ==
  37. self.warehouse_inventory)
  38. self.rule_buy.onchange_move_type()
  39. self.assertTrue(self.rule_buy.warehouse_id == self.warehouse_supplier)
  40. self.rule_sell_return.onchange_move_type()
  41. self.assertTrue(self.rule_sell_return.warehouse_id ==
  42. self.warehouse_customer)
  43. def test_compute_warehouse_dest_impl(self):
  44. ''' 根据单据类型自动填充上调入仓库 '''
  45. self.rule_sell.onchange_move_type()
  46. self.assertTrue(self.rule_sell.warehouse_dest_id ==
  47. self.warehouse_customer)
  48. self.rule_buy_return.onchange_move_type()
  49. self.assertTrue(self.rule_buy_return.warehouse_dest_id ==
  50. self.warehouse_supplier)
  51. self.rule_wh_out.onchange_move_type()
  52. self.assertTrue(self.rule_wh_out.warehouse_dest_id ==
  53. self.warehouse_others)
  54. self.rule_wh_out_inv.onchange_move_type()
  55. self.assertTrue(self.rule_wh_out_inv.warehouse_dest_id ==
  56. self.warehouse_inventory)
  57. def test_qc_rule_sell_delivery_done(self):
  58. ''' 满足质检规则但未上传质检报告,应报错:请先上传质检报告 '''
  59. self.rule_wh_in.onchange_move_type()
  60. self.rule_wh_in.warehouse_dest_id = self.env.ref('warehouse.hd_stock')
  61. wh_in_others = self.env.ref('warehouse.wh_in_whin3')
  62. with self.assertRaises(UserError):
  63. wh_in_others.approve_order()
上海开阖软件有限公司 沪ICP备12045867号-1