[MERGE] hr_timesheet, project_timesheet: clean yml tests

bzr revid: rco@openerp.com-20111221110536-9vfz4m8q1rievlie
This commit is contained in:
Raphael Collet 2011-12-21 12:05:36 +01:00
commit 5c0e461eda
8 changed files with 108 additions and 224 deletions

View File

@ -56,18 +56,18 @@ class account_change_currency(osv.osv_memory):
if invoice.company_id.currency_id.id == invoice.currency_id.id:
new_price = line.price_unit * rate
if new_price <= 0:
raise osv.except_osv(_('Error'), _('New currency is not confirured properly !'))
raise osv.except_osv(_('Error'), _('New currency is not configured properly !'))
if invoice.company_id.currency_id.id != invoice.currency_id.id and invoice.company_id.currency_id.id == new_currency:
old_rate = invoice.currency_id.rate
if old_rate <= 0:
raise osv.except_osv(_('Error'), _('Currnt currency is not confirured properly !'))
raise osv.except_osv(_('Error'), _('Current currency is not configured properly !'))
new_price = line.price_unit / old_rate
if invoice.company_id.currency_id.id != invoice.currency_id.id and invoice.company_id.currency_id.id != new_currency:
old_rate = invoice.currency_id.rate
if old_rate <= 0:
raise osv.except_osv(_('Error'), _('Current currency is not confirured properly !'))
raise osv.except_osv(_('Error'), _('Current currency is not configured properly !'))
new_price = (line.price_unit / old_rate ) * rate
obj_inv_line.write(cr, uid, [line.id], {'price_unit': new_price})
obj_inv.write(cr, uid, [invoice.id], {'currency_id': new_currency}, context=context)

View File

@ -56,9 +56,11 @@ to set up a management by affair.
'hr_timesheet_installer.xml',
],
'demo_xml': ['hr_timesheet_demo.xml'],
'test': ['test/test_hr_timesheet.yml',
'test/hr_timesheet_report.yml',
],
'test': [
'test/test_hr_timesheet.yml',
'test/hr_timesheet_report.yml',
'test/hr_timesheet_demo.yml',
],
'installable': True,
'active': False,
'certificate': '0071405533469',

View File

@ -0,0 +1,6 @@
-
!record {model: hr.analytic.timesheet, id: working_hours_coding, view: False}:
user_id: base.user_demo
date: !eval time.strftime('%Y-%m-%d')
account_id: account.analytic_administratif
unit_amount: 1.0

View File

@ -1,149 +1,51 @@
-
In order to test hr_timesheet Module in OpenERP, I make "Sign In/Sign Out for Project" to encode and
track time spent on the different projects.
-
I create a new employee “Mark Johnson” to test Timesheet.
I create employee "Quentin Paolino" as "User".
-
!record {model: hr.employee, id: hr_employee_employee0}:
address_home_id: base.res_partner_address_1
company_id: base.main_company
gender: male
marital: single
name: Mark Johnson
user_id: base.user_root
-
I create new user "test_timesheet_user1".
-
!record {model: res.users, id: test_timesheet_user1}:
company_id: base.main_company
context_lang: en_US
groups_id:
- base.group_hr_user
- base.group_user
- base.group_extended
- base.group_hr_manager
login: test_timesheet_user1
name: test_timesheet_user1
password: test_timesheet_user1
-
I create another new employee "Francline" as "test_timesheet_user1".
-
!record {model: hr.employee, id: hr_employee_fracline1}:
!record {model: hr.employee, id: hr.employee2}:
address_home_id: base.res_partner_address_8
name: Francline
parent_id: 'hr_employee_employee0'
user_id: 'test_timesheet_user1'
-
I create a product as "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 assigned product and journal to "Mark Johnson"
-
!record {model: hr.employee, id: hr_employee_employee0}:
product_id: product_consultant
journal_id: analytic_journal
-
I assigned product and journal to "Francline".
-
!record {model: hr.employee, id: hr_employee_fracline1}:
product_id: product_consultant
journal_id: analytic_journal
-
I create attendance and perform "Sign In" action with proper reason.
-
!record {model: hr.attendance, id: hr_attendance_0}:
action: sign_in
employee_id: 'hr_employee_fracline1'
name: !eval (datetime.now()-timedelta(hours=2)).strftime('%Y-%m-%d %H:%M:%S')
-
I create attendance and perform "Sign Out" action.
-
!record {model: hr.attendance, id: hr_attendance_1}:
action: sign_out
employee_id: 'hr_employee_fracline1'
name: !eval (datetime.now()-timedelta(hours=1)).strftime('%Y-%m-%d %H:%M:%S')
name: Quentin Paolino
parent_id: 'hr.employee3'
user_id: 'base.user_demo'
-
On "Sign In/Sign Out by Project" wizard i click on "Sign In/Sign Out" button of this wizard.
-
!python {model: hr.sign.in.project}: |
uid = ref('test_timesheet_user1')
self.check_state(cr, uid, [ref("hr_employee_fracline1")], {"active_ids": [ref("hr_timesheet.action_hr_timesheet_sign_in")]})
uid = ref('base.user_demo')
state_id = self.check_state(cr, uid, [ref("hr.employee2")], {"active_ids": [ref("hr_timesheet.action_hr_timesheet_sign_in")]})
assert state_id['name'] == 'Sign in / Sign out', "Check the process of sing-in/sing-out."
-
I select start date and Perform start work on project.
-
!python {model: hr.sign.in.project}: |
import time
uid = ref('test_timesheet_user1')
new_id = self.create(cr, uid, {'emp_id': ref('hr_employee_fracline1'), 'name': 'Francline', 'server_date': time.strftime('%Y-%m-%d %H:%M:%S'), 'state': 'absent'})
self.sign_in_result(cr, uid, [new_id], context)
import time
uid = ref('base.user_demo')
new_id = self.create(cr, uid, {'emp_id': ref('hr.employee2'), 'name': 'Quentin Paolino',
'server_date': time.strftime('%Y-%m-%d %H:%M:%S'), 'state': 'present'})
self.sign_in_result(cr, uid, [new_id], context)
-
I create a timesheet line manually to check several default values.
I also assign proper date and user for that line.
-
!python {model: hr.analytic.timesheet}: |
import time
uid = ref('test_timesheet_user1')
current_date = time.strftime('%Y-%m-%d')
vals = {'name': 'Worked on project',
'user_id': ref('test_timesheet_user1'),
'account_id': ref('account.analytic_project_1_development'),
'unit_amount': 5.00,
'journal_id': ref('analytic_journal')
}
line_id = self.create(cr, uid, vals, None)
res = self.on_change_date(cr, uid, [line_id], current_date)
values = dict([('date', current_date)] + res['value'].items())
res1 = self.on_change_user_id(cr, uid, [line_id], ref('base.user_root'))
values.update(dict([('user_id', ref('base.user_root'))] + res1['value'].items()))
self.write(cr, uid, [line_id], values, None)
-
To stop work I click on "Sign In/Sign Out" button of "Sign In/Sign Out by Project" wizard.
Which check state in hr attendace form for user.
-
!python {model: hr.sign.in.project}: |
uid = ref('test_timesheet_user1')
ids = self.search(cr, uid, [('emp_id', '=', ref('hr_employee_fracline1')),('name', '=', 'Francline')])
self.check_state(cr, uid, ids, {"active_ids": [ref("hr_timesheet.action_hr_timesheet_sign_in")]
})
-
I Create an analytic account "Project2".
-
!record {model: account.analytic.account, id: account_analytic_account_project0}:
company_id: base.main_company
name: Project2
parent_id: account.analytic_root
quantity_max: 0.0
state: open
-
My work for this project is over and I stop working by clicking on "Stop Work" button of this wizard.
I change my project "Thymbra" and I click on the "Change Work" button of this wizard
-
!python {model: hr.sign.out.project}: |
import time
from datetime import datetime, date, timedelta
uid = ref('test_timesheet_user1')
new_id = self.create(cr, uid, {'account_id': ref('account_analytic_account_project0'), 'analytic_amount': 7.0, 'date': (datetime.now()+timedelta(1)).strftime('%Y-%m-%d %H:%M:%S'), 'date_start': time.strftime('%Y-%m-%d %H:%M:%S'), 'info': 'Create Yaml for hr module', 'name': 'Francline', 'server_date': time.strftime('%Y-%m-%d %H:%M:%S'), 'state': 'absent'})
self.sign_out_result_end(cr, uid, [new_id], context)
- |
I can see employee timesheet for particular month using "Employee Timesheet" report.
import time
from datetime import datetime, date, timedelta
uid = ref('base.user_demo')
new_id = self.create(cr, uid, {'account_id': ref('account.analytic_thymbra'),'analytic_amount': 7.0,
'date': (datetime.now()+timedelta(1)).strftime('%Y-%m-%d %H:%M:%S') ,
'date_start': time.strftime('%Y-%m-%d %H:%M:%S'), 'info': 'Create Yaml for hr module',
'name': 'Quentin Paolino', 'server_date': time.strftime('%Y-%m-%d %H:%M:%S'), 'state': 'action'})
self.sign_out_result(cr, uid, [new_id], context)
-
My work for this project "Sednacom" is over and I stop working by clicking on "Stop Work" button of this wizard.
-
!python {model: hr.sign.out.project}: |
import time
from datetime import datetime, date, timedelta
uid = ref('base.user_demo')
new_id = self.create(cr, uid, {'account_id': ref('account.analytic_sednacom'), 'analytic_amount': 7.0,
'date': (datetime.now()+timedelta(2)).strftime('%Y-%m-%d %H:%M:%S'),
'date_start': time.strftime('%Y-%m-%d %H:%M:%S'), 'info': 'Create Yaml for hr module',
'name': 'Quentin Paolino', 'server_date': time.strftime('%Y-%m-%d %H:%M:%S'), 'state': 'absent'})
self.sign_out_result_end(cr, uid, [new_id], context)

View File

@ -1,89 +1,61 @@
-
In order to test hr_timesheet_sheet module in OpenERP, I create timesheet and check validation process done by manager.
In order to test hr_timesheet_sheet module in OpenERP,
I create Timesheet and check validation process done by manager.
-
I create a new employee "Mark Johnson".
I assign this product(Service on Timesheet) and journal(Timesheet Journal) to employee "Quentin Paolino"
-
!record {model: hr.employee, id: hr_employee_employee0}:
address_home_id: base.res_partner_address_1
gender: male
marital: single
name: Mark Johnson
user_id: base.user_demo
!record {model: hr.employee, id: hr.employee2}:
product_id: product.product_consultant
journal_id: hr_timesheet.analytic_journal
-
I create new Timesheet journal for employee.
I create my current timesheet for employee "Quentin Paolinon".
-
!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: !eval time.strftime('%Y-%m-%d')
date_from: !eval time.strftime('%Y-%m-01')
name: !eval time.strftime('%U')
name: Quentin Paolinon
state: new
user_id: base.user_demo
employee_id: 'hr_employee_employee0'
employee_id: 'hr.employee2'
-
Now, at the time of login, I create Attendances and perform "Sign In" action.
-
!python {model: hr_timesheet_sheet.sheet}:
!python {model: hr_timesheet_sheet.sheet}: |
self.sign_in(cr, uid, [ref('hr_timesheet_sheet_sheet_deddk0')], {})
task_work = self.search(cr, uid, [("name","=","Quentin Paolinon")],context)[0]
task_ids = self.browse(cr, uid, task_work, context)
assert task_ids.state == "draft", "I State In Timesheet"
-
I want to check attendance and work of yesterday. I click on <- button.
-
!python {model: hr_timesheet_sheet.sheet}: |
self.date_previous(cr, uid, [ref('hr_timesheet_sheet_sheet_deddk0')], None)
date_prev = self.date_previous(cr, uid, [ref('hr_timesheet_sheet_sheet_deddk0')], None)
assert date_prev == True, "I See Previous Date Timesheet"
-
Then I click on "Today" button to fill today's timesheet.
-
!python {model: hr_timesheet_sheet.sheet}: |
self.date_today(cr, uid, [ref('hr_timesheet_sheet_sheet_deddk0')], None)
-
I want to go to a particular date and see attendance then I select the date and click on "Go to:" button.
-
!python {model: hr_timesheet_sheet.sheet}: |
self.button_dummy(cr, uid, [ref('hr_timesheet_sheet_sheet_deddk0')], None)
date_to = self.date_today(cr, uid, [ref('hr_timesheet_sheet_sheet_deddk0')], None)
assert date_to == True, "I See Today Date Timesheet"
-
I can also move to next day by clicking on -> button.
-
!python {model: hr_timesheet_sheet.sheet}: |
self.date_next(cr, uid, [ref('hr_timesheet_sheet_sheet_deddk0')], None)
date_next = self.date_next(cr, uid, [ref('hr_timesheet_sheet_sheet_deddk0')], None)
assert date_next == True, "I See Next Date Timesheet"
-
I want to go to a particular date and see attendance then I select the date and click on "Go to:" button.
-
!python {model: hr_timesheet_sheet.sheet}: |
button_dumy = self.button_dummy(cr, uid, [ref('hr_timesheet_sheet_sheet_deddk0')], None)
assert button_dumy == True, "I See Particular Date Attendance"
-
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'
employee_id: 'hr.employee2'
name: !eval time.strftime('%Y-%m-%d')+' '+'%s:%s:%s' %(min(23,datetime.now().hour+2),min(59,datetime.now().minute+1),min(59,datetime.now().second+1))
-
I create Timesheet Entry for time spend on today work.
-
@ -94,27 +66,23 @@
name: 'Develop yaml for hr module'
unit_amount: 3.00
amount: -90.00
product_id: product_consultant
product_id: product.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.
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"),
self.button_confirm(cr, uid, [ref('hr_timesheet_sheet_sheet_deddk0')], {"active_ids":
[ref("hr_timesheet_sheet.menu_act_hr_timesheet_sheet_form")],"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.
-
@ -125,31 +93,26 @@
name: 'Develop yaml for hr module'
unit_amount: 2.0
amount: -90.00
product_id: product_consultant
product_id: product.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"),
self.button_confirm(cr, uid, [ref('hr_timesheet_sheet_sheet_deddk0')], {"active_ids":
[ref("hr_timesheet_sheet.menu_act_hr_timesheet_sheet_form")],"active_id": ref("hr_timesheet_sheet.menu_act_hr_timesheet_sheet_form"),
})
-
This time timesheet confirmed successfully.
I check that state is "Confirmed".
I check that state is "Confirmed".
-
!assert {model: hr_timesheet_sheet.sheet, id: hr_timesheet_sheet_sheet_deddk0}:
- state == 'confirm'
- 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'})
@ -157,5 +120,4 @@
I check that state is "Done".
-
!assert {model: hr_timesheet_sheet.sheet, id: hr_timesheet_sheet_sheet_deddk0}:
- state == 'done'
- state == 'done'

View File

@ -40,6 +40,7 @@ the Timesheet line entries for particular date and particular user with the eff
'demo_xml': ["project_timesheet_demo.xml"],
'test': [
'test/worktask_entry_to_timesheetline_entry.yml',
'test/work_timesheet.yml',
],
'installable': True,
'active': False,

View File

@ -0,0 +1,21 @@
-
I set task work entry for Employee
-
!record {model: project.task.work, id: project_task_work1}:
date: !eval time.strftime('%Y-%m-%d %H:%M:%S')
name: Test Timesheet records
task_id: project.project_task_1
hours: 20.0
user_id: project.res_users_analyst
company_id: base.main_company
-
I check Timesheet line for employee in current Timesheet
-
!python {model: hr.analytic.timesheet}: |
import datetime
start = (datetime.date.today().strftime('%Y-%m-%d'))
task_work = self.search(cr, uid, [("name","=","Prepare Requirements Document: Test Timesheet records")],context)[0]
task_ids = self.browse(cr, uid, task_work, context)
assert task_ids.user_id.id == ref("project.res_users_analyst"), 'Error, The User in Timesheet is not Correct'
assert task_ids.date == start, 'Error, The Date in Timesheet is not ok'
assert task_ids.product_uom_id.name == "Hour", 'Error, The Hour in Timesheet is not ok'

View File

@ -9,7 +9,6 @@
password: hr
groups_id:
- base.group_hr_manager
-
Create a product with type service used to specify employees designation
-
@ -28,7 +27,6 @@
warranty: 0.0
weight: 0.0
weight_net: 0.0
-
Create an analytic journal for employees timesheet
-
@ -36,7 +34,6 @@
company_id: base.main_company
name: HR Timesheet
type: general
-
Create an employee 'HR Manager' for user 'HR Manager'
-
@ -45,7 +42,6 @@
user_id: res_users_hrmanager0
product_id: product_product_hrmanger0
journal_id: account_analytic_journal_hrtimesheet0
-
Create a timesheet sheet for HR manager
-
@ -57,15 +53,12 @@
state: new
user_id: res_users_hrmanager0
employee_id : 'hr_employee_hrmanager0'
-
Create a project 'Timesheet Management'
-
!record {model: project.project, id: project_project_timesheetmanagement0}:
company_id: base.main_company
name: Timesheet Management
-
Create a task 'Get all timesheet records'
-
@ -77,7 +70,6 @@
remaining_hours: 20.0
state: draft
user_id: res_users_hrmanager0
-
Open the task
-
@ -86,7 +78,6 @@
"en_US", "active_ids": [ref("project_project_timesheetmanagement0")], "tz":
False, "active_model": "project.project", "department_id": False, "project_id":
False, "active_id": ref("project_project_timesheetmanagement0"), })
-
Make a work task entry 'Get work calendar of all employees' of 10 hours done by HR manager
-
@ -96,9 +87,8 @@
hours: 10.0
name: Get work calendar of all employees
user_id: res_users_hrmanager0
-
Check for timesheet_ids in HR manager's timesheet
-
!assert {model: hr_timesheet_sheet.sheet, id: hr_timesheet_sheet_sheet_sheetforhrmanager0, string: After hr manager's work task, length of timesheet line of current timesheet must be greater then 1}:
- len(timesheet_ids) > 0
- len(timesheet_ids) > 0