common.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. # Part of Odoo. See LICENSE file for full copyright and licensing details.
  2. from datetime import datetime
  3. from freezegun import freeze_time
  4. from odoo.tests import common, new_test_user
  5. class TestsCommon(common.TransactionCase):
  6. @classmethod
  7. def setUpClass(cls):
  8. super().setUpClass()
  9. cls.fakenow = datetime(2021, 1, 29, 12, 20, 0)
  10. cls.startClassPatcher(freeze_time(cls.fakenow))
  11. def setUp(self):
  12. super(TestsCommon, self).setUp()
  13. self.env['lunch.cashmove'].create({
  14. 'amount': 100,
  15. })
  16. self.manager = new_test_user(self.env, 'cle-lunch-manager', 'base.group_user,base.group_partner_manager,lunch.group_lunch_manager')
  17. with self.with_user('cle-lunch-manager'):
  18. self.location_office_1 = self.env['lunch.location'].create({
  19. 'name' : 'Farm 1',
  20. })
  21. self.location_office_2 = self.env['lunch.location'].create({
  22. 'name': 'Farm 2',
  23. })
  24. self.partner_pizza_inn = self.env['res.partner'].create({
  25. 'name': 'Pizza Inn',
  26. })
  27. self.supplier_pizza_inn = self.env['lunch.supplier'].create({
  28. 'partner_id': self.partner_pizza_inn.id,
  29. 'send_by': 'mail',
  30. 'automatic_email_time': 11,
  31. 'available_location_ids': [
  32. (6, 0, [self.location_office_1.id, self.location_office_2.id])
  33. ],
  34. })
  35. self.partner_kothai = self.env['res.partner'].create({
  36. 'name': 'Kothai',
  37. })
  38. self.supplier_kothai = self.env['lunch.supplier'].create({
  39. 'partner_id': self.partner_kothai.id,
  40. 'send_by': 'mail',
  41. 'automatic_email_time': 10,
  42. 'tz': 'America/New_York',
  43. })
  44. self.partner_coin_gourmand = self.env['res.partner'].create({
  45. 'name': 'Coin Gourmand',
  46. })
  47. self.supplier_coin_gourmand = self.env['lunch.supplier'].create({
  48. 'partner_id': self.partner_coin_gourmand.id,
  49. 'send_by': 'phone',
  50. 'available_location_ids': [
  51. (6, 0, [self.location_office_1.id, self.location_office_2.id])
  52. ],
  53. })
  54. self.category_pizza = self.env['lunch.product.category'].create({
  55. 'name': 'Pizza',
  56. })
  57. self.category_sandwich = self.env['lunch.product.category'].create({
  58. 'name': 'Sandwich',
  59. })
  60. self.product_pizza = self.env['lunch.product'].create({
  61. 'name': 'Pizza',
  62. 'category_id': self.category_pizza.id,
  63. 'price': 9,
  64. 'supplier_id': self.supplier_pizza_inn.id,
  65. })
  66. self.product_sandwich_tuna = self.env['lunch.product'].create({
  67. 'name': 'Tuna Sandwich',
  68. 'category_id': self.category_sandwich.id,
  69. 'price': 3,
  70. 'supplier_id': self.supplier_coin_gourmand.id,
  71. })
  72. self.topping_olives = self.env['lunch.topping'].create({
  73. 'name': 'Olives',
  74. 'price': 0.3,
  75. 'supplier_id': self.supplier_pizza_inn.id,
  76. })
  77. self.env['lunch.cashmove'].create({
  78. 'amount': 100,
  79. })
  80. self.alert_ny = self.env['lunch.alert'].create({
  81. 'name': 'New York UTC-5',
  82. 'mode': 'chat',
  83. 'notification_time': 10,
  84. 'notification_moment': 'am',
  85. 'tz': 'America/New_York',
  86. 'message': "",
  87. }).with_context(tz='America/New_York')
  88. self.alert_tokyo = self.env['lunch.alert'].create({
  89. 'name': 'Tokyo UTC+9',
  90. 'mode': 'chat',
  91. 'notification_time': 8,
  92. 'notification_moment': 'am',
  93. 'tz': 'Asia/Tokyo',
  94. 'message': "",
  95. }).with_context(tz='Asia/Tokyo')