From 540134eff201fda537bd5d6273093b9cae17baee Mon Sep 17 00:00:00 2001 From: "Hemendra Paregi (Open ERP)" Date: Fri, 9 Dec 2011 12:11:32 +0530 Subject: [PATCH 1/4] [MERGE]Improvement in yml file bzr revid: hpa@tinyerp.com-20111209064132-88p4ym4t451xqrwf --- .../hr_timesheet/test/test_hr_timesheet.yml | 122 +++--------------- .../test/test_hr_timesheet_sheet.yml | 94 ++++---------- addons/project_timesheet/__openerp__.py | 1 + .../project_timesheet/test/work_timesheet.yml | 32 +++++ 4 files changed, 76 insertions(+), 173 deletions(-) create mode 100644 addons/project_timesheet/test/work_timesheet.yml diff --git a/addons/hr_timesheet/test/test_hr_timesheet.yml b/addons/hr_timesheet/test/test_hr_timesheet.yml index 30c97c3eb70..3635f59fb3c 100644 --- a/addons/hr_timesheet/test/test_hr_timesheet.yml +++ b/addons/hr_timesheet/test/test_hr_timesheet.yml @@ -1,110 +1,38 @@ - 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') + self.check_state(cr, uid, [ref("hr.employee2")], {"active_ids": [ref("hr_timesheet.action_hr_timesheet_sign_in")]}) - 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'}) + 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': 'absent'}) self.sign_in_result(cr, uid, [new_id], context) - - I create a timesheet line manually to check several default values. + 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') + uid = ref('base.user_demo') current_date = time.strftime('%Y-%m-%d') vals = {'name': 'Worked on project', - 'user_id': ref('test_timesheet_user1'), + 'user_id': ref('base.user_demo'), 'account_id': ref('account.analytic_project_1_development'), 'unit_amount': 5.00, 'journal_id': ref('analytic_journal') @@ -120,30 +48,16 @@ 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')]) + uid = ref('base.user_demo') + ids = self.search(cr, uid, [('emp_id', '=', ref('hr.employee2')),('name', '=', 'Quentin Paolino')]) 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. + My work for this project 1 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('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. - + uid = ref('base.user_demo') + new_id = self.create(cr, uid, {'account_id': ref('account.analytic_project_1'), '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) \ No newline at end of file diff --git a/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml b/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml index 58b1b38ad2f..3aede6bd15b 100644 --- a/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml +++ b/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml @@ -1,56 +1,22 @@ - - 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 and 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: !eval time.strftime('%U') 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. - @@ -66,24 +32,23 @@ - !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) - 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) +- + 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) - 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 +59,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,25 +86,21 @@ 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' @@ -157,5 +114,4 @@ I check that state is "Done". - !assert {model: hr_timesheet_sheet.sheet, id: hr_timesheet_sheet_sheet_deddk0}: - - state == 'done' - + - state == 'done' \ No newline at end of file diff --git a/addons/project_timesheet/__openerp__.py b/addons/project_timesheet/__openerp__.py index b90d3d745a1..7cd36e770ab 100644 --- a/addons/project_timesheet/__openerp__.py +++ b/addons/project_timesheet/__openerp__.py @@ -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, diff --git a/addons/project_timesheet/test/work_timesheet.yml b/addons/project_timesheet/test/work_timesheet.yml new file mode 100644 index 00000000000..129840c74d9 --- /dev/null +++ b/addons/project_timesheet/test/work_timesheet.yml @@ -0,0 +1,32 @@ +- + I set 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 set timesheet line for employee in current timesheet +- + !python {model: hr.analytic.timesheet}: | + import datetime + uid = ref('project.res_users_analyst') + current_date = (datetime.date.today().strftime('%Y-%m-%d')) + vals = {'name': 'Test Timesheet records', + 'user_id': ref('project.res_users_analyst'), + 'account_id': ref('account.analytic_project_1_development'), + 'unit_amount': 5.00, + 'journal_id': ref('hr_timesheet.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('project.res_users_analyst')) + values.update(dict([('user_id', ref('project.res_users_analyst'))] + res1['value'].items())) + self.write(cr, uid, [line_id], values, None) + + + From 98cf8b318cd93adf16d4489d138e6fe017ca56cc Mon Sep 17 00:00:00 2001 From: "Hemendra Paregi (Open ERP)" Date: Tue, 20 Dec 2011 12:20:42 +0530 Subject: [PATCH 2/4] [IMP] Improvement in YML bzr revid: hpa@tinyerp.com-20111220065042-m4ebxsy2tl04yzf1 --- addons/hr_timesheet/__openerp__.py | 4 +- .../hr_timesheet/test/hr_timesheet_demo.yml | 6 ++ .../hr_timesheet/test/test_hr_timesheet.yml | 68 ++++++++----------- .../wizard/hr_timesheet_sign_in_out.py | 1 + .../test/test_hr_timesheet_sheet.yml | 22 +++--- .../project_timesheet/test/work_timesheet.yml | 29 +++----- .../worktask_entry_to_timesheetline_entry.yml | 12 +--- 7 files changed, 62 insertions(+), 80 deletions(-) create mode 100644 addons/hr_timesheet/test/hr_timesheet_demo.yml diff --git a/addons/hr_timesheet/__openerp__.py b/addons/hr_timesheet/__openerp__.py index 43f5e62e37c..e572190610e 100644 --- a/addons/hr_timesheet/__openerp__.py +++ b/addons/hr_timesheet/__openerp__.py @@ -56,8 +56,10 @@ to set up a management by affair. 'hr_timesheet_installer.xml', ], 'demo_xml': ['hr_timesheet_demo.xml'], - 'test': ['test/test_hr_timesheet.yml', + 'test': [ + 'test/test_hr_timesheet.yml', 'test/hr_timesheet_report.yml', + 'test/hr_timesheet_demo.yml', ], 'installable': True, 'active': False, diff --git a/addons/hr_timesheet/test/hr_timesheet_demo.yml b/addons/hr_timesheet/test/hr_timesheet_demo.yml new file mode 100644 index 00000000000..755f21a0500 --- /dev/null +++ b/addons/hr_timesheet/test/hr_timesheet_demo.yml @@ -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 \ No newline at end of file diff --git a/addons/hr_timesheet/test/test_hr_timesheet.yml b/addons/hr_timesheet/test/test_hr_timesheet.yml index 3635f59fb3c..fdca798e0c9 100644 --- a/addons/hr_timesheet/test/test_hr_timesheet.yml +++ b/addons/hr_timesheet/test/test_hr_timesheet.yml @@ -14,50 +14,38 @@ - !python {model: hr.sign.in.project}: | uid = ref('base.user_demo') - self.check_state(cr, uid, [ref("hr.employee2")], {"active_ids": [ref("hr_timesheet.action_hr_timesheet_sign_in")]}) + 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('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': '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('base.user_demo') - current_date = time.strftime('%Y-%m-%d') - vals = {'name': 'Worked on project', - 'user_id': ref('base.user_demo'), - '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('base.user_demo') - ids = self.search(cr, uid, [('emp_id', '=', ref('hr.employee2')),('name', '=', 'Quentin Paolino')]) - self.check_state(cr, uid, ids, {"active_ids": [ref("hr_timesheet.action_hr_timesheet_sign_in")] - }) -- - My work for this project 1 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('base.user_demo') - new_id = self.create(cr, uid, {'account_id': ref('account.analytic_project_1'), '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) \ No newline at end of file + 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) \ No newline at end of file diff --git a/addons/hr_timesheet/wizard/hr_timesheet_sign_in_out.py b/addons/hr_timesheet/wizard/hr_timesheet_sign_in_out.py index e3f7f0c7acb..8931b125844 100644 --- a/addons/hr_timesheet/wizard/hr_timesheet_sign_in_out.py +++ b/addons/hr_timesheet/wizard/hr_timesheet_sign_in_out.py @@ -88,6 +88,7 @@ class hr_so_project(osv.osv_memory): return timesheet_obj.create(cr, uid, res, context=context) def sign_out_result_end(self, cr, uid, ids, context=None): + print"" emp_obj = self.pool.get('hr.employee') for data in self.browse(cr, uid, ids, context=context): emp_id = data.emp_id.id diff --git a/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml b/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml index 3aede6bd15b..f86d85f527a 100644 --- a/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml +++ b/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml @@ -2,7 +2,7 @@ In order to test hr_timesheet_sheet module in OpenERP, I create Timesheet and check validation process done by manager. - - I assign this product and journal to employee "Quentin Paolino" + I assign this product(Service on Timesheet) and journal(Timesheet Journal) to employee "Quentin Paolino" - !record {model: hr.employee, id: hr.employee2}: product_id: product.product_consultant @@ -13,35 +13,42 @@ !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.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) + 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}: | - self.button_dummy(cr, uid, [ref('hr_timesheet_sheet_sheet_deddk0')], None) + 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". - @@ -106,7 +113,6 @@ - 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'}) diff --git a/addons/project_timesheet/test/work_timesheet.yml b/addons/project_timesheet/test/work_timesheet.yml index 129840c74d9..a53fd766567 100644 --- a/addons/project_timesheet/test/work_timesheet.yml +++ b/addons/project_timesheet/test/work_timesheet.yml @@ -1,5 +1,5 @@ - - I set work entry for employee + 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') @@ -9,24 +9,13 @@ user_id: project.res_users_analyst company_id: base.main_company - - I set timesheet line for employee in current timesheet + I check Timesheet line for employee in current Timesheet - !python {model: hr.analytic.timesheet}: | - import datetime - uid = ref('project.res_users_analyst') - current_date = (datetime.date.today().strftime('%Y-%m-%d')) - vals = {'name': 'Test Timesheet records', - 'user_id': ref('project.res_users_analyst'), - 'account_id': ref('account.analytic_project_1_development'), - 'unit_amount': 5.00, - 'journal_id': ref('hr_timesheet.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('project.res_users_analyst')) - values.update(dict([('user_id', ref('project.res_users_analyst'))] + res1['value'].items())) - self.write(cr, uid, [line_id], values, None) - - - + 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' \ No newline at end of file diff --git a/addons/project_timesheet/test/worktask_entry_to_timesheetline_entry.yml b/addons/project_timesheet/test/worktask_entry_to_timesheetline_entry.yml index f524c214821..3635a7ec8fb 100644 --- a/addons/project_timesheet/test/worktask_entry_to_timesheetline_entry.yml +++ b/addons/project_timesheet/test/worktask_entry_to_timesheetline_entry.yml @@ -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 \ No newline at end of file From 04379ea4d6aacdb30a8ff354073069a80f4f2702 Mon Sep 17 00:00:00 2001 From: Purnendu Singh <> Date: Tue, 20 Dec 2011 13:02:40 +0530 Subject: [PATCH 3/4] [FIX] account : Corrected spelling mistakes in warning messages of account/wizard/account_change_currency.py lp bug: https://launchpad.net/bugs/906752 fixed bzr revid: bde@tinyerp.com-20111220073240-9o2epnidg6itemht --- addons/account/wizard/account_change_currency.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/account/wizard/account_change_currency.py b/addons/account/wizard/account_change_currency.py index eb4319a56b6..fc460eceb11 100644 --- a/addons/account/wizard/account_change_currency.py +++ b/addons/account/wizard/account_change_currency.py @@ -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) From bc40611002a5bed155973925007dc650041f06c9 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Wed, 21 Dec 2011 11:52:14 +0100 Subject: [PATCH 4/4] [IMP] hr_timesheet: small code and test cleanup bzr revid: rco@openerp.com-20111221105214-kgwedzef47lvoii8 --- addons/hr_timesheet/__openerp__.py | 8 ++++---- addons/hr_timesheet/test/hr_timesheet_demo.yml | 2 +- addons/hr_timesheet/test/test_hr_timesheet.yml | 2 +- addons/hr_timesheet/wizard/hr_timesheet_sign_in_out.py | 1 - .../hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml | 4 ++-- addons/project_timesheet/test/work_timesheet.yml | 2 +- .../test/worktask_entry_to_timesheetline_entry.yml | 2 +- 7 files changed, 10 insertions(+), 11 deletions(-) diff --git a/addons/hr_timesheet/__openerp__.py b/addons/hr_timesheet/__openerp__.py index f276fa24757..247a763fe10 100644 --- a/addons/hr_timesheet/__openerp__.py +++ b/addons/hr_timesheet/__openerp__.py @@ -57,10 +57,10 @@ to set up a management by affair. ], 'demo_xml': ['hr_timesheet_demo.xml'], 'test': [ - 'test/test_hr_timesheet.yml', - 'test/hr_timesheet_report.yml', - 'test/hr_timesheet_demo.yml', - ], + 'test/test_hr_timesheet.yml', + 'test/hr_timesheet_report.yml', + 'test/hr_timesheet_demo.yml', + ], 'installable': True, 'active': False, 'certificate': '0071405533469', diff --git a/addons/hr_timesheet/test/hr_timesheet_demo.yml b/addons/hr_timesheet/test/hr_timesheet_demo.yml index 755f21a0500..a868be2d710 100644 --- a/addons/hr_timesheet/test/hr_timesheet_demo.yml +++ b/addons/hr_timesheet/test/hr_timesheet_demo.yml @@ -3,4 +3,4 @@ user_id: base.user_demo date: !eval time.strftime('%Y-%m-%d') account_id: account.analytic_administratif - unit_amount: 1.0 \ No newline at end of file + unit_amount: 1.0 diff --git a/addons/hr_timesheet/test/test_hr_timesheet.yml b/addons/hr_timesheet/test/test_hr_timesheet.yml index fdca798e0c9..19c72a46d2b 100644 --- a/addons/hr_timesheet/test/test_hr_timesheet.yml +++ b/addons/hr_timesheet/test/test_hr_timesheet.yml @@ -48,4 +48,4 @@ '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) \ No newline at end of file + self.sign_out_result_end(cr, uid, [new_id], context) diff --git a/addons/hr_timesheet/wizard/hr_timesheet_sign_in_out.py b/addons/hr_timesheet/wizard/hr_timesheet_sign_in_out.py index 8931b125844..e3f7f0c7acb 100644 --- a/addons/hr_timesheet/wizard/hr_timesheet_sign_in_out.py +++ b/addons/hr_timesheet/wizard/hr_timesheet_sign_in_out.py @@ -88,7 +88,6 @@ class hr_so_project(osv.osv_memory): return timesheet_obj.create(cr, uid, res, context=context) def sign_out_result_end(self, cr, uid, ids, context=None): - print"" emp_obj = self.pool.get('hr.employee') for data in self.browse(cr, uid, ids, context=context): emp_id = data.emp_id.id diff --git a/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml b/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml index f86d85f527a..1cb97ca8afd 100644 --- a/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml +++ b/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml @@ -110,7 +110,7 @@ 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. - @@ -120,4 +120,4 @@ I check that state is "Done". - !assert {model: hr_timesheet_sheet.sheet, id: hr_timesheet_sheet_sheet_deddk0}: - - state == 'done' \ No newline at end of file + - state == 'done' diff --git a/addons/project_timesheet/test/work_timesheet.yml b/addons/project_timesheet/test/work_timesheet.yml index a53fd766567..d9c1212c022 100644 --- a/addons/project_timesheet/test/work_timesheet.yml +++ b/addons/project_timesheet/test/work_timesheet.yml @@ -18,4 +18,4 @@ 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' \ No newline at end of file + assert task_ids.product_uom_id.name == "Hour", 'Error, The Hour in Timesheet is not ok' diff --git a/addons/project_timesheet/test/worktask_entry_to_timesheetline_entry.yml b/addons/project_timesheet/test/worktask_entry_to_timesheetline_entry.yml index 3635a7ec8fb..a6ccc63749a 100644 --- a/addons/project_timesheet/test/worktask_entry_to_timesheetline_entry.yml +++ b/addons/project_timesheet/test/worktask_entry_to_timesheetline_entry.yml @@ -91,4 +91,4 @@ 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 \ No newline at end of file + - len(timesheet_ids) > 0