Skip to content

Commit

Permalink
Merge pull request #1822 from Judystudy/master
Browse files Browse the repository at this point in the history
[ADD] 添加 goods get_tax_rate 测试数据
  • Loading branch information
USI-SHRD committed Jun 15, 2018
2 parents 77b528a + bc01290 commit bab072f
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions goods/tests/test_goods.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,37 @@ def test_copy(self):
mouse = self.goods_mouse.copy()
self.assertEqual(u'鼠标 (copy)', mouse.name)

def test_get_tax_rate(self):
''' Test: get tax rate '''
fruits_vegetables = self.env.ref('goods.fruits_vegetables')
partner_services = self.env.ref('goods.partner_services')
fruits_vegetables.parent_id = partner_services.id

# 取产品上的税率
fruits_vegetables.tax_rate = 10.0
self.goods_mouse.goods_class_id = fruits_vegetables.id
mouse_tax_rate = self.goods_mouse.get_tax_rate(self.goods_mouse, False, 'buy')
self.assertEqual(mouse_tax_rate, 10.0)

# 取末级 产品分类 上的税率
fruits_vegetables.tax_rate = False
partner_services.tax_rate = 11.0
mouse_tax_rate = self.goods_mouse.get_tax_rate(self.goods_mouse, False, 'buy')
self.assertEqual(mouse_tax_rate, 11.0)

# 逐级取 产品分类 上的 税率
partner_services.tax_rate = False
goods_class_first = self.env['goods.class'].create({
'name': '顶级分类',
'tax_rate': 12.0
})
partner_services.parent_id = goods_class_first.id
mouse_tax_rate = self.goods_mouse.get_tax_rate(self.goods_mouse, False, 'buy')
self.assertEqual(mouse_tax_rate, 12.0)

# no goods
self.goods_mouse.get_tax_rate(False, False, 'buy')


class TestAttributes(TransactionCase):

Expand All @@ -99,3 +130,6 @@ def test_ean_search(self):
real_result = [(iphone_value_white.id,
iphone_value_white.category_id.name + ':' + iphone_value_white.value_id.name)]
self.assertEqual(result, real_result)

# return super
self.env['attribute'].name_search('123')

0 comments on commit bab072f

Please sign in to comment.