GoodERP
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

57 rindas
2.6KB

  1. from odoo.tests.common import TransactionCase
  2. from odoo.exceptions import UserError, ValidationError
  3. class TestMonthProductCost(TransactionCase):
  4. def setUp(self):
  5. super(TestMonthProductCost, self).setUp()
  6. self.period_id = self.env.ref('finance.period_201601')
  7. self.period_id_15 = self.env.ref('finance.period_201512')
  8. def test_generate_issue_cost(self):
  9. """本月成本结算 相关逻辑的测试"""
  10. checkout_wizard_row = self.env['checkout.wizard'].create(
  11. {'date': '2016-01-31', 'period_id': self.period_id.id})
  12. with self.assertRaises(UserError):
  13. checkout_wizard_row.button_checkout()
  14. # sell_delivery_rows = self.env['sell.delivery'].search([('type','=','others')])
  15. wh_in_rows = self.env['wh.in'].search([('state','!=','done')])
  16. wh_in_rows.write({'date': '2016-01-31'})
  17. wh_out_rows = self.env['wh.out'].search(
  18. [('name', '=', self.env.ref('warehouse.wh_out_whout1').name)])
  19. wh_out_rows.write({'date': '2016-01-31'})
  20. # wh_internal_rows = self.env['wh.internal'].search([])
  21. # [sell_delivery_row.sell_delivery_done() for sell_delivery_row in sell_delivery_rows]
  22. [wh_in_row.approve_order() for wh_in_row in wh_in_rows]
  23. [wh_out_row.approve_order() for wh_out_row in wh_out_rows]
  24. # [wh_internal_row.approve_order() for wh_internal_row in wh_internal_rows]
  25. self.env['month.product.cost'].generate_issue_cost(
  26. self.period_id, '2016-01-31')
  27. # 离输入期间最近的 对应产品的发出成本行 存在
  28. wh_in_rows = self.env['wh.in'].search([])
  29. wh_in_rows.write({'date': '2015-12-31'})
  30. self.env['month.product.cost'].generate_issue_cost(
  31. self.period_id_15, '2015-12-31')
  32. wh_out_2 = self.env.ref('warehouse.wh_out_whout1')
  33. wh_out_2.write({'date': '2016-1-31'})
  34. self.env['month.product.cost'].generate_issue_cost(
  35. self.period_id, '2016-01-31')
  36. # 计算发出成本 取实际成本
  37. company = self.env['res.company'].search([], limit=1)
  38. company.cost_method = 'fifo'
  39. self.env['month.product.cost'].generate_issue_cost(
  40. self.period_id, '2016-01-31')
  41. class TestPartner(TransactionCase):
  42. def test_action_view_sell_history(self):
  43. """ 测试 客户采购记录(最近一年)"""
  44. customer_yixun = self.env.ref('core.yixun')
  45. customer_yixun.action_view_sell_history()
  46. # 测试 时间间隔大于1年的 if
  47. self.env.user.company_id.start_date = '2016-01-01'
  48. customer_yixun.action_view_sell_history()
上海开阖软件有限公司 沪ICP备12045867号-1