[FIX] fixed yml tests due to removed fields on account payments
[odoo/odoo.git] / addons / hr_payroll_account / test / hr_payroll_account.yml
1 -
2   I test the "Payslip" in order to check the hr_payroll_account module in OpenERP
3 -
4   I create a bank record
5 -
6   !record {model: res.partner.bank, id: res_partner_bank_0}:
7     acc_number: '001-9876543-21'
8     partner_id: base.res_partner_desertic_hispafuentes
9     state: bank
10     bank: base.res_bank_1
11 -
12   I create a new employee "John"
13 -
14   !record {model: hr.employee, id: hr_employee_john}:
15     address_home_id: base.res_partner_address_2
16     address_id: base.res_partner_address_9
17     birthday: '1984-05-01'
18     children: 0.0
19     country_id: base.in
20     department_id: hr.dep_it
21     gender: male
22     marital: single
23     name: John
24     bank_account_id: res_partner_bank_0
25     vehicle_distance: 0.0
26 -
27   I create a salary structure for 'Software Developer'
28 -
29   !record {model: hr.payroll.structure, id: hr_payroll_structure_softwaredeveloper}:
30     name: Salary Structure for Software Developer
31     code: SD
32     company_id: base.main_company
33     parent_id: hr_payroll.structure_base
34     rule_ids:
35       - hr_payroll.hr_salary_rule_houserentallowance1
36       - hr_payroll.hr_salary_rule_convanceallowance1
37       - hr_payroll.hr_salary_rule_professionaltax1
38       - hr_payroll.hr_salary_rule_providentfund1
39       - hr_payroll.hr_salary_rule_meal_voucher
40       - hr_payroll.hr_salary_rule_sales_commission
41 -
42   I create a contract for "John"
43 -
44   !record {model: hr.contract, id: hr_contract_john}:
45     date_end: !eval "'%s-%s-%s' %(datetime.now().year+1,datetime.now().month,datetime.now().day)"
46     date_start: !eval time.strftime('%Y-%m-%d')
47     name: Contract for John
48     wage: 5000.0
49     type_id: hr_contract.hr_contract_type_emp
50     employee_id: hr_employee_john
51     struct_id: hr_payroll_structure_softwaredeveloper
52     working_hours: resource.timesheet_group1
53 -
54   I create a Payslip
55 -
56   !record {model: hr.payslip, id: hr_payslip_0}:
57     employee_id: hr_employee_john
58     journal_id: account.expenses_journal
59 -
60   The selection of an employee fills the contract, structure, worked days and input data fields
61 -
62   !python {model: hr.payslip}: |
63     import time
64     from datetime import datetime
65     from dateutil import relativedelta
66     date_from = time.strftime('%Y-%m-01')
67     worked_days_obj = self.pool.get('hr.payslip.worked_days')
68     date_to = str(datetime.now() + relativedelta.relativedelta(months=+1, day=1, days=-1))[:10]
69     res = self.onchange_employee_id(cr, uid, [], date_from, date_to, ref("hr_employee_john"), False, None)
70     vals = {
71       'struct_id': res['value']['struct_id'],
72       'contract_id': res['value']['contract_id'],
73       'name': res['value']['name'],
74       }
75     vals['worked_days_line_ids'] = [(0,0,i) for i in res['value']['worked_days_line_ids']]
76     vals['input_line_ids'] = [(0,0,i) for i in res['value']['input_line_ids']]
77     self.write(cr, uid, ref("hr_payslip_0"), vals)
78 -
79   I assign the amount to Input data
80 -
81   !python {model: hr.payslip.input}: |
82     ids = self.search(cr, uid, [('payslip_id', '=', ref("hr_payslip_0"))])
83     self.write(cr, uid, ids, {'amount': 5.0})
84 -
85   I verify the payslip is in draft state
86 -
87   !python {model: hr.payslip}: |
88     from tools.translate import _
89     payslip_brw=self.browse(cr, uid, ref("hr_payslip_0"))
90     assert(payslip_brw.state == 'draft'), _('State not changed!')
91 -
92   I click on "Compute Sheet" button
93 -
94   !python {model: hr.payslip}: |
95     self.compute_sheet(cr, uid, [ref("hr_payslip_0")], {"lang": "en_US", "tz": False,
96       "active_model": "ir.ui.menu", "department_id": False, "active_ids": [ref("hr_payroll.menu_department_tree")],
97       "section_id": False, "active_id": ref("hr_payroll.menu_department_tree"),
98       })
99 -
100   Then I click on the "Confirm" button
101 -
102   !workflow {model: hr.payslip, action: hr_verify_sheet, ref: hr_payslip_0}
103 -
104   I verify that the Accounting Entries are created
105 -
106   !python {model: hr.payslip}: |
107     payslip = self.browse(cr, uid, ref("hr_payslip_0"))
108     assert payslip.move_id, "Accounting Entries has not been created"
109 -
110   I verify that the payslip is in done state
111 -
112   !python {model: hr.payslip}: |
113     from tools.translate import _
114     payslip_brw=self.browse(cr, uid, ref("hr_payslip_0"))
115     assert(payslip_brw.state == 'done'), _('State not changed!')