[IMP] hr, hr_xxx: Improved yamls to save data fetched from on change methods.
authorUjjvala Collins (OpenERP) <uco@tinyerp.com>
Tue, 8 Nov 2011 09:33:29 +0000 (15:03 +0530)
committerUjjvala Collins (OpenERP) <uco@tinyerp.com>
Tue, 8 Nov 2011 09:33:29 +0000 (15:03 +0530)
bzr revid: uco@tinyerp.com-20111108093329-sgfisy6uyb6dr2bi

addons/hr/test/test_hr.yml
addons/hr_evaluation/test/test_hr_evaluation.yml
addons/hr_expense/test/test_hr_expense.yml
addons/hr_holidays/test/test_hr_holiday.yml
addons/hr_payroll_account/test/hr_payroll_account.yml
addons/hr_recruitment/test/test_hr_recruitment.yml
addons/hr_timesheet/test/test_hr_timesheet.yml
addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml

index f4fa77a..7b4ba82 100644 (file)
   I change the company of the employee.
 -
   !python {model: hr.employee}: |
-    self.onchange_company(cr, uid, [ref('hr_employee_mark')], ref('base.main_company'), None)
+    res = self.onchange_company(cr, uid, [ref('hr_employee_mark')], ref('base.main_company'), None)
+    values = dict([('company_id', ref('base.main_company'))] + res['value'].items())
+    self.write(cr, uid, [ref('hr_employee_mark')], values, None)
 -
   I assign department for employee “Mark Johnson”.
 -
   !python {model: hr.employee}: |
     res = self.onchange_department_id(cr, uid, [ref('hr_employee_mark')], ref('hr_department_rd0'), None)
     assert res['value']['parent_id']
+    values = dict([('department_id', ref('hr_department_rd0'))] + res['value'].items())
+    self.write(cr, uid, [ref('hr_employee_mark')], values, None)
 -
   Now I create a user for employee “Mark Johnson”.
 -
@@ -41,6 +45,8 @@
 -
   !python {model: hr.employee}: |
     res = self.onchange_user(cr, uid, [ref('hr_employee_mark')], ref('hr_users_markjohnson0'), None)
+    values = dict([('user_id', ref('hr_users_markjohnson0'))] + res['value'].items())
+    self.write(cr, uid, [ref('hr_employee_mark')], values, None)
 -
   In order to check the wizard “Employee Hierarchy” , I will create new employee “Phil Graves” and select “Mark Johnson” as
   Manager.
@@ -58,6 +64,8 @@
   !python {model: hr.employee}: |
     res = self.onchange_address_id(cr, uid, ref('hr_employee_phil'), ref('base.res_partner_address_3000'), None)
     assert res['value']
+    values = dict([('address_id', ref('base.res_partner_address_3000'))] + res['value'].items())
+    self.write(cr, uid, [ref('hr_employee_phil')], values, None)
 -
   I will open up form view of  “Mark Johnson” and test the wizard “Employee Hierarchy” so it display the employee
   hierarchy starting from “Mark Johnson”.
   !python {model: hr.job}: |
     res = self.on_change_expected_employee(cr, uid, [ref('hr_job_jea0')], 6, 3, None)
     assert res['value']['expected_employees']
+    values = dict([('expected_employees', ref('hr_job_jea0'))] + res['value'].items())
+    self.write(cr, uid, [ref('hr_job_jea0')], values, None)
 -
   I open the job position for recruitment.
 -
index 926ad57..893f19d 100644 (file)
 -
   !python {model: hr.employee}: |
     res = self.onchange_evaluation_plan_id(cr, uid, [ref('hr_employee_employee0')], ref('hr_evaluation_plan_managersplan0'), False, None)
+    values = dict([('evaluation_plan_id', ref('hr_evaluation_plan_managersplan0'))] + res['value'].items())
+    self.write(cr, uid, [ref('hr_employee_employee0')], values, None)
 -
   I create an Evaluation for employee under "Manager Evaluation Plan".
 -
   I change the employee on Evaluation.
 -
   !python {model: hr_evaluation.evaluation}: |
-    self.onchange_employee_id(cr, uid, [ref('hr_evaluation_evaluation_0')], ref('hr_employee_employee0'), None)
+    res = self.onchange_employee_id(cr, uid, [ref('hr_evaluation_evaluation_0')], ref('hr_employee_employee0'), None)
+    values = dict([('employee_id', ref('hr_employee_employee0'))] + res['value'].items())
+    self.write(cr, uid, [ref('hr_evaluation_evaluation_0')], values, None)
 -
   I start the evaluation process by click on "Start Evaluation" button.
 -
index 6f70031..bd13529 100644 (file)
@@ -74,7 +74,9 @@
   I change the employee on expense form.
 -
   !python {model: hr.expense.expense}: |
-    self.onchange_employee_id(cr, uid, [ref('hr_expense_expense_september0')], ref('hr.employee1'), None)
+    res = self.onchange_employee_id(cr, uid, [ref('hr_expense_expense_september0')], ref('hr.employee1'), None)
+    values = dict([('employee_id', ref('hr.employee1'))] + res['value'].items())
+    self.write(cr, uid, [ref('hr_expense_expense_september0')], values, None)
 -
   Now I change the related product on expense line.
 -
@@ -82,7 +84,9 @@
     exp_line_obj = self.pool.get('hr.expense.line')
     exp_obj = self.browse(cr, uid, ref('hr_expense_expense_september0'), None)
     line_ids = [line.id for line in exp_obj.line_ids]
-    exp_line_obj.onchange_product_id(cr, uid, line_ids, ref('product_product_expense_air'), False, ref('hr.employee1'), None)
+    res = exp_line_obj.onchange_product_id(cr, uid, line_ids, ref('product_product_expense_air'), False, ref('hr.employee1'), None)
+    values = dict([('product_id', ref('product_product_expense_air'))] + res['value'].items())
+    exp_line_obj.write(cr, uid, line_ids, values, None)
 -
   I confirm this expenses by click on "Confirm" button.
 -
index 720636d..c4a8476 100644 (file)
@@ -57,7 +57,9 @@
   I change Leave Type of the employee.
 -
   !python {model: hr.holidays}: |
-    self.onchange_sec_id(cr, uid, [ref('hr_holidays_allocateleaveforuser0')], ref('holiday_status_sl'))
+    res = self.onchange_sec_id(cr, uid, [ref('hr_holidays_allocateleaveforuser0')], ref('holiday_status_sl'))
+    values = dict([('holiday_status_id', ref('holiday_status_sl'))] + res['value'].items())
+    self.write(cr, uid, [ref('hr_holidays_allocateleaveforuser0')], values, None)
 -
   I assign the dates in the holiday request.
 -
@@ -65,7 +67,9 @@
     from datetime import datetime
     date_from = '%s-%s-%s 14:00:00' %(datetime.now().year, datetime.now().month, datetime.now().day)
     date_to = '%s-%s-%s 19:59:00' %(datetime.now().year, datetime.now().month, datetime.now().day)
-    self.onchange_date_from(cr, uid, [ref('hr_holidays_allocateleaveforuser0')], date_to, date_from)
+    res = self.onchange_date_from(cr, uid, [ref('hr_holidays_allocateleaveforuser0')], date_to, date_from)
+    values = dict([('date_from', date_from),('date_to',date_to)] + res['value'].items())
+    self.write(cr, uid, [ref('hr_holidays_allocateleaveforuser0')], values, None)
 -
   I confirmed the allocation by clicking on "Confirm" button.
 -
index 778eeb1..4481f53 100644 (file)
     employee_id: hr_employee_john
     struct_id: hr_payroll_structure_softwaredeveloper
     working_hours: resource.timesheet_group1
+    journal_id: account.expenses_journal
 -
   I create a Payslip.
 -
   !record {model: hr.payslip, id: hr_payslip_0}:
     employee_id: hr_employee_john
     journal_id: account.expenses_journal
--
-  I assign contract in the payslip.
--
-  !python {model: hr.payslip}: |
-    import time
-    from datetime import datetime
-    date_from = '%s-%s-%s' %(datetime.now().year+1,datetime.now().month,datetime.now().day)
-    date_to = time.strftime('%Y-%m-%d')
-    self.onchange_contract_id(cr, uid, [ref('hr_payslip_0')], date_from, date_to, ref('hr_employee_john'), ref('hr_contract_john'), None)
+
 -
   The selection of an employee fills the contract, structure, worked days and input data fields.
 -
       'struct_id': res['value']['struct_id'],
       'contract_id': res['value']['contract_id'],
       'name': res['value']['name'],
-      }
+    }
     vals['worked_days_line_ids'] = [(0,0,i) for i in res['value']['worked_days_line_ids']]
     vals['input_line_ids'] = [(0,0,i) for i in res['value']['input_line_ids']]
+    res_contract = self.onchange_contract_id(cr, uid, [ref('hr_payslip_0')], date_from, date_to, ref('hr_employee_john'), ref('hr_contract_john'), None)
+    vals.update({'contract_id': ref('hr_contract_john')})
     self.write(cr, uid, ref("hr_payslip_0"), vals)
 -
   I assign the amount to Input data.
index 14d61c4..b797353 100644 (file)
   I assign the position to the applicant and its relevant department.
 -
   !python {model: hr.applicant}: |
-     self.onchange_job(cr, uid, [ref('hr_applicant_fresher0')], ref('hr.job_jr_developers'), None)
-     self.onchange_department_id(cr, uid, [ref('hr_applicant_fresher0')], ref('hr.dep_it'), None)
+     res = self.onchange_job(cr, uid, [ref('hr_applicant_fresher0')], ref('hr.job_jr_developers'), None)
+     values = dict([('job_id', ref('hr.job_jr_developers'))] + res['value'].items())
+     res1 = self.onchange_department_id(cr, uid, [ref('hr_applicant_fresher0')], ref('hr.dep_it'), None)
+     values.update(dict([('department_id', ref('hr.dep_it'))] + res1['value'].items()))
+     self.write(cr, uid, [ref('hr_applicant_fresher0')], values, None)
 -
   On a successful meeting with the applicant, I hired employee by click on "Hired" button.
 -
index 9b30994..30c97c3 100644 (file)
              'journal_id': ref('analytic_journal')
      }
      line_id = self.create(cr, uid, vals, None)
-     self.on_change_date(cr, uid, [line_id], current_date)
-     self.on_change_user_id(cr, uid, [line_id], ref('base.user_root'))
+     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.
index c847b9c..24ffe3b 100644 (file)
@@ -74,7 +74,7 @@
   Now, at the time of login, I create Attendances and perform "Sign In" action.
 -
   !python {model: hr_timesheet_sheet.sheet}:
-    self.sign_in(cr, uid, [ref('hr_timesheet_sheet_sheet_deddk0')], None)
+    self.sign_in(cr, uid, [ref('hr_timesheet_sheet_sheet_deddk0')], {})
 -
   I want to check attendance and work of yesterday. I click on <- button.
 -