-
  In order to test hr_timesheet_sheet module in OpenERP, I create timesheet and check validation process done by manager.
-
  I will create a company and set maximum allowed difference between timesheet and attendance to 1 hour
-
  !record {model: res.company, id: res_company_openERP}:
    currency_id: base.ARS
    name: OpenERP SA
    partner_id: base.res_partner_desertic_hispafuentes
    timesheet_max_difference: 1.0

-
  I assign this company to Admin user
-
  !record {model: res.users, id: base.user_root}:
    company_id: res_company_openERP
    company_ids:
      - base.main_company
      - res_company_openERP

-
  I  create a new employee “Mark Johnson”.
-
  !record {model: hr.employee, id: hr_employee_employee0}:
    address_home_id: base.res_partner_address_1
    company_id: res_company_openERP
    gender: male
    marital: hr.hr_employee_marital_status_single
    name: Mark Johnson
    user_id: base.user_root

-
  I create new Timesheet journal for employee.
-
  !record {model: account.analytic.journal, id: analytic_journal}:
    code: TS
    name: Timesheet Journal
    type: general

-
  I create a new product "Consultancy - Senior Developer".
-
  !record {model: product.product, id: product_consultant}:
    categ_id: product.product_category_10
    default_code: DEV
    list_price: 75.0
    name: Consultancy - Senior Developer
    procure_method: make_to_order
    purchase_ok: False
    standard_price: 30.0
    supply_method: produce
    type: service
    uom_id: product.uom_hour
    uom_po_id: product.uom_hour

-
  I assign this product and journal to  "Mark Johnson"
-
  !record {model: hr.employee, id: hr_employee_employee0}:
    product_id: product_consultant
    journal_id: analytic_journal

-
  I create my current timesheet for "Mark Johnson".
-
  !record {model: hr_timesheet_sheet.sheet, id: hr_timesheet_sheet_sheet_deddk0}:
    date_current: '2010-05-26'
    date_from: '2010-05-01'
    date_to: '2010-05-31'
    name: Week-22(2010)
    state: new
    user_id: base.user_root
-
  Now , at the time of login, I create Attendances and perform "Sign In" action.
-
  !record {model: hr.attendance, id: hr_attendance_0}:
    action: sign_in
    employee_id: 'hr_employee_employee0'
    name: '2010-05-26 10:08:08'

-
  At the time of logout, I create attendance and perform "Sign Out".
-
  !record {model: hr.attendance, id: hr_attendance_1}:
    action: sign_out
    employee_id: 'hr_employee_employee0'
    name: '2010-05-26 15:10:55'

-
  I create Timesheet Entry for time spend on today work.

-
  !record {model: hr_timesheet_sheet.sheet, id: hr_timesheet_sheet_sheet_deddk0}:
    timesheet_ids:
      - account_id: account.analytic_sednacom
        date: '2010-05-26'
        name: 'Develop yaml for hr module'
        unit_amount: 3.00
        amount: -90.00
        product_id: hr_timesheet.product_consultant
        general_account_id: account.a_expense
        user_id: base.user_root
        journal_id: hr_timesheet.analytic_journal

-
  I confirm my timesheet at end of period by click on "Confirm" button,
   if the difference between timesheet hour and attendance hour is more than 1 hour it will give message.
-
  !python {model: hr_timesheet_sheet.sheet}: |
        uid = ref('base.user_root')
        import netsvc
        try:
            self.button_confirm(cr, uid, [ref('hr_timesheet_sheet_sheet_deddk0')], {"lang": 'en_US', "active_ids":
              [ref("hr_timesheet_sheet.menu_act_hr_timesheet_sheet_form")], "tz": False, "active_model":
              "ir.ui.menu", "department_id": False, "section_id": False, "search_default_my_timesheet":
              1, "search_default_user_id": 1, "project_id": False, "active_id": ref("hr_timesheet_sheet.menu_act_hr_timesheet_sheet_form"),
              })
        except:
            pass

-
  I Modified the timesheet record and make the difference less than 1 hour.
-
  !record {model: hr_timesheet_sheet.sheet, id: hr_timesheet_sheet_sheet_deddk0}:
    timesheet_ids:
      - account_id: account.analytic_sednacom
        date: '2010-05-26'
        name: 'Develop yaml for hr module'
        unit_amount: 2.0
        amount: -90.00
        product_id: hr_timesheet.product_consultant
        general_account_id: account.a_expense
        user_id: base.user_root
        journal_id: hr_timesheet.analytic_journal

-
  I tried again to confirm the timesheet after modification.
-
  !python {model: hr_timesheet_sheet.sheet}: |
        uid = ref('base.user_root')
        self.button_confirm(cr, uid, [ref('hr_timesheet_sheet_sheet_deddk0')], {"lang": 'en_US', "active_ids":
          [ref("hr_timesheet_sheet.menu_act_hr_timesheet_sheet_form")], "tz": False, "active_model":
          "ir.ui.menu", "department_id": False, "section_id": False, "search_default_my_timesheet":
          1, "search_default_user_id": 1, "project_id": False, "active_id": ref("hr_timesheet_sheet.menu_act_hr_timesheet_sheet_form"),
          })

-
  This time timesheet confirmed successfully.
   I check that state is "Confirmed".
-
  !assert {model: hr_timesheet_sheet.sheet, id: hr_timesheet_sheet_sheet_deddk0}:
      - state == 'confirm'
-
  The manager will accept This request by click on "Accept" button.

-
  !python {model: hr_timesheet_sheet.sheet}: |
    self.write(cr, uid, [ref('hr_timesheet_sheet_sheet_deddk0')], {'state': 'done'})
-
  I check that state is "Done".
-
  !assert {model: hr_timesheet_sheet.sheet, id: hr_timesheet_sheet_sheet_deddk0}:
      - state == 'done'

