test_pos_setup.py 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # -*- coding: utf-8 -*-
  2. # Part of Odoo. See LICENSE file for full copyright and licensing details.
  3. from odoo import tools
  4. import odoo
  5. from odoo.addons.point_of_sale.tests.common import TestPoSCommon
  6. @odoo.tests.tagged('post_install', '-at_install')
  7. class TestPoSSetup(TestPoSCommon):
  8. """ This group of tests is for sanity check in setting up global records which will be used
  9. in each testing.
  10. If a test fails here, then it means there are inconsistencies in what we expect in the setup.
  11. """
  12. def setUp(self):
  13. super(TestPoSSetup, self).setUp()
  14. self.config = self.basic_config
  15. self.products = [
  16. self.create_product('Product 1', self.categ_basic, lst_price=10.0, standard_price=5),
  17. self.create_product('Product 2', self.categ_basic, lst_price=20.0, standard_price=10),
  18. self.create_product('Product 3', self.categ_basic, lst_price=30.0, standard_price=15),
  19. ]
  20. def test_basic_config_values(self):
  21. config = self.basic_config
  22. self.assertEqual(config.currency_id, self.company_currency)
  23. self.assertEqual(config.pricelist_id.currency_id, self.company_currency)
  24. def test_other_currency_config_values(self):
  25. config = self.other_currency_config
  26. self.assertEqual(config.currency_id, self.other_currency)
  27. self.assertEqual(config.pricelist_id.currency_id, self.other_currency)
  28. def test_product_categories(self):
  29. # check basic product category
  30. # it is expected to have standard and manual_periodic valuation
  31. self.assertEqual(self.categ_basic.property_cost_method, 'standard')
  32. self.assertEqual(self.categ_basic.property_valuation, 'manual_periodic')
  33. # check anglo saxon product category
  34. # this product categ is expected to have fifo and real_time valuation
  35. self.assertEqual(self.categ_anglo.property_cost_method, 'fifo')
  36. self.assertEqual(self.categ_anglo.property_valuation, 'real_time')
  37. def test_product_price(self):
  38. def get_price(pricelist, product):
  39. return pricelist._get_product_price(product, 1)
  40. # check usd pricelist
  41. pricelist = self.basic_config.pricelist_id
  42. for product in self.products:
  43. self.assertAlmostEqual(get_price(pricelist, product), product.lst_price)
  44. # check eur pricelist
  45. # exchange rate to the other currency is set to 0.5, thus, lst_price
  46. # is expected to have half its original value.
  47. pricelist = self.other_currency_config.pricelist_id
  48. for product in self.products:
  49. self.assertAlmostEqual(get_price(pricelist, product), product.lst_price * 0.5)
  50. def test_taxes(self):
  51. tax7 = self.taxes['tax7']
  52. self.assertEqual(tax7.name, 'Tax 7%')
  53. self.assertAlmostEqual(tax7.amount, 7)
  54. self.assertEqual(tax7.invoice_repartition_line_ids.mapped('account_id').id, self.tax_received_account.id)
  55. tax10 = self.taxes['tax10']
  56. self.assertEqual(tax10.name, 'Tax 10%')
  57. self.assertAlmostEqual(tax10.amount, 10)
  58. self.assertEqual(tax10.price_include, True)
  59. self.assertEqual(tax10.invoice_repartition_line_ids.mapped('account_id').id, self.tax_received_account.id)
  60. tax_group_7_10 = self.taxes['tax_group_7_10']
  61. self.assertEqual(tax_group_7_10.name, 'Tax 7+10%')
  62. self.assertEqual(tax_group_7_10.amount_type, 'group')
  63. self.assertEqual(sorted(tax_group_7_10.children_tax_ids.ids), sorted((tax7 | tax10).ids))