[IMP] Cleanup the test case on hr_expense
bzr revid: jap@tinyerp.com-20111123053937-z5umq72sncompwf3
This commit is contained in:
parent
c7de208ffa
commit
5636b7f0af
|
@ -62,8 +62,8 @@ re-invoice your customer's expenses if your work by project.
|
|||
'demo_xml': [
|
||||
'hr_expense_demo.xml',
|
||||
],
|
||||
'test': ['test/test_hr_expense.yml',
|
||||
'test/hr_expense_report.yml',
|
||||
'test': [
|
||||
'test/confirm2heldinvoiced.yml',
|
||||
],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
-
|
||||
In Order to test process of Employee Expenses.
|
||||
-
|
||||
I create this expense.
|
||||
-
|
||||
!workflow {model: hr.expense.expense, action: confirm, ref: hr_expense_expense_septemberexpenses0}
|
||||
-
|
||||
I change the state of expense.
|
||||
-
|
||||
!python {model: hr.expense.expense}: |
|
||||
self.expense_confirm(cr, uid, [ref('hr_expense_expense_septemberexpenses0')])
|
||||
-
|
||||
I check the the expense is created or not
|
||||
-
|
||||
!assert {model: hr.expense.expense, id: hr_expense_expense_septemberexpenses0}:
|
||||
- state == 'confirm'
|
||||
-
|
||||
I accept this expense.
|
||||
-
|
||||
!workflow {model: hr.expense.expense, action: validate, ref: hr_expense_expense_septemberexpenses0}
|
||||
-
|
||||
I assign home address to employee.
|
||||
-
|
||||
!record {model: hr.employee, id: hr.employee1}:
|
||||
address_home_id: base.res_partner_address_1
|
||||
address_id: base.main_address
|
||||
-
|
||||
I create the Invoiced for the expense.
|
||||
-
|
||||
!python {model: hr.expense.expense}: |
|
||||
self.invoice(cr, uid, [ref('hr_expense_expense_septemberexpenses0')])
|
||||
|
||||
-
|
||||
I check that expense is "Invoiced".
|
||||
-
|
||||
!assert {model: hr.expense.expense, id: hr_expense_expense_septemberexpenses0}:
|
||||
- state == 'invoiced'
|
||||
-
|
||||
I check that Invoice is created for the expense.
|
||||
-
|
||||
!python {model: hr.expense.expense}: |
|
||||
exp = self.browse(cr, uid, [ref('hr_expense_expense_septemberexpenses0')])[0]
|
||||
assert exp.invoice_id, "Invoice should be created"
|
||||
-
|
||||
I paid the expense
|
||||
-
|
||||
!python {model: hr.expense.expense}: |
|
||||
self.expense_paid(cr, uid, [ref('hr_expense_expense_septemberexpenses0')])
|
||||
-
|
||||
I check the expense is paid.
|
||||
-
|
||||
!assert {model: hr.expense.expense, id: hr_expense_expense_septemberexpenses0}:
|
||||
- state == 'paid'
|
||||
-
|
||||
I cancel the expense
|
||||
-
|
||||
!python {model: hr.expense.expense}: |
|
||||
self.expense_canceled(cr, uid, [ref('hr_expense_expense_septemberexpenses0')])
|
||||
-
|
||||
I check the expense is cancel.
|
||||
-
|
||||
!assert {model: hr.expense.expense, id: hr_expense_expense_septemberexpenses0}:
|
||||
- state == 'cancelled'
|
||||
-
|
||||
we will print a PDF report defined on a HR Expense.
|
||||
-
|
||||
!python {model: hr.expense.expense}: |
|
||||
import netsvc, tools, os
|
||||
(data, format) = netsvc.LocalService('report.hr.expense').create(cr, uid, [ref('hr_expense.hr_expense_expense_septemberexpenses0'),ref('hr_expense.hr_expense_expense_septemberexpenses1')], {}, {})
|
||||
if tools.config['test_report_directory']:
|
||||
file(os.path.join(tools.config['test_report_directory'], 'hr_expense-report.'+format), 'wb+').write(data)
|
|
@ -1,8 +0,0 @@
|
|||
-
|
||||
In order to test the PDF reports defined on a HR Expense, we will print a HR Expense
|
||||
-
|
||||
!python {model: hr.expense.expense}: |
|
||||
import netsvc, tools, os
|
||||
(data, format) = netsvc.LocalService('report.hr.expense').create(cr, uid, [ref('hr_expense.hr_expense_expense_septemberexpenses0'),ref('hr_expense.hr_expense_expense_septemberexpenses1')], {}, {})
|
||||
if tools.config['test_report_directory']:
|
||||
file(os.path.join(tools.config['test_report_directory'], 'hr_expense-report.'+format), 'wb+').write(data)
|
|
@ -1,121 +0,0 @@
|
|||
-
|
||||
In order to test hr_expenses for OpenERP, I create expenses for employee and manage employee's expenses.
|
||||
-
|
||||
I create an unit of measure category "Working Time".
|
||||
-
|
||||
!record {model: product.uom.categ, id: product_uom_categ_workingtime0}:
|
||||
name: Working Time.
|
||||
|
||||
-
|
||||
I create a new employee.
|
||||
-
|
||||
!record {model: hr.employee, id: hr.employee}:
|
||||
address_home_id: base.res_partner_address_1
|
||||
address_id: base.main_address
|
||||
-
|
||||
I assign home address to employee.
|
||||
-
|
||||
!record {model: hr.employee, id: hr.employee1}:
|
||||
address_home_id: base.res_partner_address_1
|
||||
address_id: base.main_address
|
||||
-
|
||||
I create product unit of measure "Hour".
|
||||
-
|
||||
!record {model: product.uom, id: product_uom_hour0}:
|
||||
category_id: 'product_uom_categ_workingtime0'
|
||||
factor: 8.0
|
||||
name: Hour
|
||||
rounding: 0.01
|
||||
-
|
||||
I Create a product "travel".
|
||||
-
|
||||
!record {model: product.product, id: product_product_travel0}:
|
||||
categ_id: product.product_category_services
|
||||
cost_method: standard
|
||||
list_price: 800.0
|
||||
mes_type: fixed
|
||||
name: Travel
|
||||
procure_method: make_to_stock
|
||||
standard_price: 700.0
|
||||
supply_method: buy
|
||||
type: product
|
||||
uom_id: 'product_uom_hour0'
|
||||
uom_po_id: 'product_uom_hour0'
|
||||
volume: 0.0
|
||||
warranty: 0.0
|
||||
weight: 0.0
|
||||
weight_net: 0.0
|
||||
-
|
||||
I mark this product for expenses.
|
||||
-
|
||||
!python {model: product.product}: |
|
||||
self.on_change_hr_expense_ok(cr, uid, [ref('product_product_travel0')], True)
|
||||
-
|
||||
I create an expense.
|
||||
-
|
||||
!record {model: hr.expense.expense, id: hr_expense_expense_september0}:
|
||||
company_id: base.main_company
|
||||
date: !eval "'%s-05-05' %(datetime.now().year)"
|
||||
name: September Expenses
|
||||
line_ids:
|
||||
- date_value: !eval "'%s-05-27' %(datetime.now().year)"
|
||||
name: Travel
|
||||
product_id: 'product_product_travel0'
|
||||
sequence: 0.0
|
||||
uom_id: product.product_uom_unit
|
||||
unit_amount: 700.0
|
||||
user_id: base.user_root
|
||||
-
|
||||
I check that expense is in "Draft" state.
|
||||
-
|
||||
!assert {model: hr.expense.expense, id: hr_expense_expense_september0}:
|
||||
- state == 'draft'
|
||||
-
|
||||
I change the employee on expense form.
|
||||
-
|
||||
!python {model: hr.expense.expense}: |
|
||||
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.
|
||||
-
|
||||
!python {model: hr.expense.expense}: |
|
||||
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]
|
||||
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.
|
||||
-
|
||||
!workflow {model: hr.expense.expense, action: confirm, ref: hr_expense_expense_september0}
|
||||
|
||||
-
|
||||
I check that state is "Waiting Confirmation".
|
||||
-
|
||||
!assert {model: hr.expense.expense, id: hr_expense_expense_september0}:
|
||||
- state == 'confirm'
|
||||
-
|
||||
I accept this expense by click on "Accept" button.
|
||||
-
|
||||
!workflow {model: hr.expense.expense, action: validate, ref: hr_expense_expense_september0}
|
||||
|
||||
-
|
||||
I invoiced this expense by click on "Invoice" button.
|
||||
-
|
||||
!python {model: hr.expense.expense}: |
|
||||
self.invoice(cr, uid, [ref('hr_expense_expense_september0')], None)
|
||||
-
|
||||
I check that state is "Invoiced".
|
||||
-
|
||||
!assert {model: hr.expense.expense, id: hr_expense_expense_september0}:
|
||||
- state == 'invoiced'
|
||||
-
|
||||
I check that Invoice is created for the expense.
|
||||
-
|
||||
!python {model: hr.expense.expense}: |
|
||||
exp = self.browse(cr, uid, [ref('hr_expense_expense_september0')])[0]
|
||||
assert exp.invoice_id, "Invoice should be created"
|
||||
|
Loading…
Reference in New Issue