예제 #1
0
    def test_calendar_working_day_intervals_leaves_generic(self):
        # Test: day0 with leaves outside range: 1 interval
        intervals = self.calendar._get_day_work_intervals(
            Date.from_string('2013-02-12'),
            start_time=time(7, 0, 0),
            compute_leaves=True)
        self.assertEqual(len(intervals), 1)
        self.assertEqual(intervals[0][:2],
                         (Datetime.from_string('2013-02-12 08:00:00'),
                          Datetime.from_string('2013-02-12 16:00:00')))

        # Test: day0 with leaves: 2 intervals because of leave between 9 and 12, ending at 15:45:30
        intervals = self.calendar._get_day_work_intervals(
            Date.from_string('2013-02-19'),
            start_time=time(8, 15, 0),
            end_time=time(15, 45, 30),
            compute_leaves=True)
        self.assertEqual(len(intervals), 2)
        self.assertEqual(intervals[0][:2],
                         (Datetime.from_string('2013-02-19 08:15:00'),
                          Datetime.from_string('2013-02-19 09:00:00')))
        self.assertEqual(intervals[1][:2],
                         (Datetime.from_string('2013-02-19 12:00:00'),
                          Datetime.from_string('2013-02-19 15:45:30')))
        self.assertEqual(intervals[0][2]['attendances'], self.att_1)
        self.assertEqual(intervals[0][2]['leaves'], self.leave1)
        self.assertEqual(intervals[1][2]['attendances'], self.att_1)
        self.assertEqual(intervals[0][2]['leaves'], self.leave1)
예제 #2
0
    def test_calendar_working_day_intervals_no_leaves(self):
        # Test: day0 without leaves: 1 interval
        intervals = self.calendar._get_day_work_intervals(
            Date.from_string('2013-02-12'), start_time=time(9, 8, 7))
        self.assertEqual(len(intervals), 1)
        self.assertEqual(intervals[0][:2],
                         (Datetime.from_string('2013-02-12 09:08:07'),
                          Datetime.from_string('2013-02-12 16:00:00')))
        self.assertEqual(intervals[0][2]['attendances'], self.att_1)

        # Test: day1, beginning at 10:30 -> work from 10:30 (arrival) until 16:00
        intervals = self.calendar._get_day_work_intervals(
            Date.from_string('2013-02-19'), start_time=time(10, 30, 0))
        self.assertEqual(len(intervals), 1)
        self.assertEqual(intervals[0][:2],
                         (Datetime.from_string('2013-02-19 10:30:00'),
                          Datetime.from_string('2013-02-19 16:00:00')))
        self.assertEqual(intervals[0][2]['attendances'], self.att_1)

        # Test: day3 without leaves: 2 interval
        intervals = self.calendar._get_day_work_intervals(
            Date.from_string('2013-02-15'), start_time=time(10, 11, 12))
        self.assertEqual(len(intervals), 2)
        self.assertEqual(intervals[0][:2],
                         (Datetime.from_string('2013-02-15 10:11:12'),
                          Datetime.from_string('2013-02-15 13:00:00')))
        self.assertEqual(intervals[1][:2],
                         (Datetime.from_string('2013-02-15 16:00:00'),
                          Datetime.from_string('2013-02-15 23:00:00')))
        self.assertEqual(intervals[0][2]['attendances'], self.att_2)
        self.assertEqual(intervals[1][2]['attendances'], self.att_3)
예제 #3
0
 def test_calendar_working_day_intervals_leaves_resource(self):
     # Test: day1+14 on leave, with resource leave computation
     intervals = self.calendar._get_day_work_intervals(
         Date.from_string('2013-02-26'),
         start_time=time(7, 0, 0),
         compute_leaves=True,
         resource_id=self.resource1_id)
     # Result: nothing, because on leave
     self.assertEqual(len(intervals), 0)
예제 #4
0
    def test_calendar_previous_day(self):
        # Test: previous day: previous day before day1 is (day4-7)
        date = self.calendar._get_previous_work_day(
            day_date=Date.from_string('2013-02-12'))
        self.assertEqual(date, self.date2.date() + relativedelta(days=-7))

        # Test: previous day: previous day before day4 is day1
        date = self.calendar._get_previous_work_day(
            day_date=Date.from_string('2013-02-15'))
        self.assertEqual(date, self.date1.date())

        # Test: previous day: previous day before day4+1 is day4
        date = self.calendar._get_previous_work_day(
            day_date=Date.from_string('2013-02-15') + relativedelta(days=1))
        self.assertEqual(date, self.date2.date())

        # Test: previous day: previous day before day1-1 is (day4-7)
        date = self.calendar._get_previous_work_day(
            day_date=Date.from_string('2013-02-12') + relativedelta(days=-1))
        self.assertEqual(date, self.date2.date() + relativedelta(days=-7))
예제 #5
0
    def test_calendar_next_day(self):
        # Test: next day: next day after day1 is day4
        date = self.calendar._get_next_work_day(
            day_date=Date.from_string('2013-02-12'))
        self.assertEqual(date, self.date2.date())

        # Test: next day: next day after day4 is (day1+7)
        date = self.calendar._get_next_work_day(
            day_date=Date.from_string('2013-02-15'))
        self.assertEqual(date, self.date1.date() + relativedelta(days=7))

        # Test: next day: next day after day4+1 is (day1+7)
        date = self.calendar._get_next_work_day(
            day_date=Date.from_string('2013-02-15') + relativedelta(days=1))
        self.assertEqual(date, self.date1.date() + relativedelta(days=7))

        # Test: next day: next day after day1-1 is day1
        date = self.calendar._get_next_work_day(
            day_date=Date.from_string('2013-02-12') + relativedelta(days=-1))
        self.assertEqual(date, self.date1.date())
예제 #6
0
    def test_account_budget(self):

        # Creating a crossovered.budget record
        budget = self.env['crossovered.budget'].create({
            'date_from':
            Date.from_string('%s-01-01' % (datetime.datetime.now().year + 1)),
            'date_to':
            Date.from_string('%s-12-31' % (datetime.datetime.now().year + 1)),
            'name':
            'Budget %s' % (datetime.datetime.now().year + 1),
            'state':
            'draft'
        })

        # I created two different budget lines
        # Modifying a crossovered.budget record
        self.env['crossovered.budget.lines'].create({
            'crossovered_budget_id':
            budget.id,
            'analytic_account_id':
            self.ref('analytic.analytic_partners_camp_to_camp'),
            'date_from':
            Date.from_string('%s-01-01' % (datetime.datetime.now().year + 1)),
            'date_to':
            Date.from_string('%s-12-31' % (datetime.datetime.now().year + 1)),
            'general_budget_id':
            self.account_budget_post_purchase0.id,
            'planned_amount':
            10000.0,
        })
        self.env['crossovered.budget.lines'].create({
            'crossovered_budget_id':
            budget.id,
            'analytic_account_id':
            self.ref('analytic.analytic_our_super_product'),
            'date_from':
            Date.from_string('%s-09-01' % (datetime.datetime.now().year + 1)),
            'date_to':
            Date.from_string('%s-09-30' % (datetime.datetime.now().year + 1)),
            'general_budget_id':
            self.account_budget_post_sales0.id,
            'planned_amount':
            400000.0,
        })
        # I check that Initially Budget is in "draft" state
        self.assertEqual(budget.state, 'draft')

        # I pressed the confirm button to confirm the Budget
        # Performing an action confirm on module crossovered.budget
        budget.action_budget_confirm()

        # I check that budget is in "Confirmed" state
        self.assertEqual(budget.state, 'confirm')

        # I pressed the validate button to validate the Budget
        # Performing an action validate on module crossovered.budget
        budget.action_budget_validate()

        # I check that budget is in "Validated" state
        self.assertEqual(budget.state, 'validate')

        # I pressed the done button to set the Budget to "Done" state
        # Performing an action done on module crossovered.budget
        budget.action_budget_done()

        # I check that budget is in "done" state
        self.assertEqual(budget.state, 'done')