File: common.py

package info (click to toggle)
odoo 18.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 878,716 kB
  • sloc: javascript: 927,937; python: 685,670; xml: 388,524; sh: 1,033; sql: 415; makefile: 26
file content (117 lines) | stat: -rw-r--r-- 4,121 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from datetime import datetime
from freezegun import freeze_time
from odoo.tests import common, new_test_user


class TestsCommon(common.TransactionCase):
    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        cls.fakenow = datetime(2021, 1, 29, 12, 20, 0)
        cls.startClassPatcher(freeze_time(cls.fakenow))

    def setUp(self):
        super(TestsCommon, self).setUp()

        self.env['lunch.cashmove'].create({
            'amount': 100,
        })

        self.manager = new_test_user(self.env, 'cle-lunch-manager', 'base.group_user,base.group_partner_manager,lunch.group_lunch_manager')
        with self.with_user('cle-lunch-manager'):

            self.location_office_1 = self.env['lunch.location'].create({
                'name' : 'Farm 1',
            })

            self.location_office_2 = self.env['lunch.location'].create({
                'name': 'Farm 2',
            })

            self.partner_pizza_inn = self.env['res.partner'].create({
                'name': 'Pizza Inn',
            })

            self.supplier_pizza_inn = self.env['lunch.supplier'].create({
                'partner_id': self.partner_pizza_inn.id,
                'send_by': 'mail',
                'automatic_email_time': 11,
                'available_location_ids': [
                    (6, 0, [self.location_office_1.id, self.location_office_2.id])
                ],
            })

            self.partner_kothai = self.env['res.partner'].create({
                'name': 'Kothai',
            })

            self.supplier_kothai = self.env['lunch.supplier'].create({
                'partner_id': self.partner_kothai.id,
                'send_by': 'mail',
                'automatic_email_time': 10,
                'tz': 'America/New_York',
            })

            self.partner_coin_gourmand = self.env['res.partner'].create({
                'name': 'Coin Gourmand',
            })

            self.supplier_coin_gourmand = self.env['lunch.supplier'].create({
                'partner_id': self.partner_coin_gourmand.id,
                'send_by': 'phone',
                'available_location_ids': [
                    (6, 0, [self.location_office_1.id, self.location_office_2.id])
                ],
            })

            self.category_pizza = self.env['lunch.product.category'].create({
                'name': 'Pizza',
            })

            self.category_sandwich = self.env['lunch.product.category'].create({
                'name': 'Sandwich',
            })

            self.product_pizza = self.env['lunch.product'].create({
                'name': 'Pizza',
                'category_id': self.category_pizza.id,
                'price': 9,
                'supplier_id': self.supplier_pizza_inn.id,
            })

            self.product_sandwich_tuna = self.env['lunch.product'].create({
                'name': 'Tuna Sandwich',
                'category_id': self.category_sandwich.id,
                'price': 3,
                'supplier_id': self.supplier_coin_gourmand.id,
            })

            self.topping_olives = self.env['lunch.topping'].create({
                'name': 'Olives',
                'price': 0.3,
                'supplier_id': self.supplier_pizza_inn.id,
            })

            self.env['lunch.cashmove'].create({
                'amount': 100,
            })

            self.alert_ny = self.env['lunch.alert'].create({
                'name': 'New York UTC-5',
                'mode': 'chat',
                'notification_time': 10,
                'notification_moment': 'am',
                'tz': 'America/New_York',
                'message': "",
            }).with_context(tz='America/New_York')

            self.alert_tokyo = self.env['lunch.alert'].create({
                'name': 'Tokyo UTC+9',
                'mode': 'chat',
                'notification_time': 8,
                'notification_moment': 'am',
                'tz': 'Asia/Tokyo',
                'message': "",
            }).with_context(tz='Asia/Tokyo')