[IMP] hr_expense: YML test cases of expenses process

bzr revid: hmo@tinyerp.com-20111128080657-tevdtnx70fbdnpbn
This commit is contained in:
Harry (OpenERP) 2011-11-28 13:36:57 +05:30
parent 5636b7f0af
commit 5f2c5a4322
6 changed files with 86 additions and 142 deletions

View File

@ -63,7 +63,7 @@ re-invoice your customer's expenses if your work by project.
'hr_expense_demo.xml',
],
'test': [
'test/confirm2heldinvoiced.yml',
'test/expense_process.yml',
],
'installable': True,
'active': False,

View File

@ -87,6 +87,7 @@ class hr_expense_expense(osv.osv):
\nIf the admin accepts it, the state is \'Accepted\'.\n If an invoice is made for the expense request, the state is \'Invoiced\'.\n If the expense is paid to user, the state is \'Reimbursed\'.'),
}
_defaults = {
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'hr.employee', context=c),
'date': lambda *a: time.strftime('%Y-%m-%d'),
'state': 'draft',
'employee_id': _employee_get,

View File

@ -8,18 +8,6 @@
<field name="parent_id" ref="product.cat0"/>
<field name="name">Expenses</field>
</record>
<record id="product_product_expense_car" model="product.product">
<field name="list_price">0.32</field>
<field name="standard_price">0.32</field>
<field name="uom_id" ref="product.product_uom_km"/>
<field name="uom_po_id" ref="product.product_uom_km"/>
<field name="type">consu</field>
<field name="name">Travel Expenses</field>
<field name="default_code">TRA</field>
<field name="categ_id" ref="hr_expense.cat_expense"/>
<field name="hr_expense_ok" eval="True" />
</record>
</data>
</openerp>
</openerp>

View File

@ -1,96 +1,76 @@
<?xml version="1.0" ?>
<openerp>
<data noupdate="1">
<data>
<record id="product_product_expense_air" model="product.product">
<field name="list_price">1.0</field>
<field name="standard_price">1.0</field>
<field name="uom_id" ref="product.product_uom_unit"/>
<field name="uom_po_id" ref="product.product_uom_unit"/>
<record id="hr.employee3" model="hr.employee">
<field name="address_home_id" ref="base.res_partner_address_1"/>
</record>
<record id="car_travel" model="product.product">
<field name="list_price">0.32</field>
<field name="type">service</field>
<field name="name">Car Travel Expenses</field>
<field name="default_code">CarTRA</field>
<field name="categ_id" ref="hr_expense.cat_expense"/>
<field name="hr_expense_ok" eval="True" />
</record>
<record id="air_ticket" model="product.product">
<field name="list_price">700.0</field>
<field name="type">service</field>
<field name="name">Air Ticket</field>
<field name="default_code">AT</field>
<field name="categ_id" ref="product.cat2"/>
<field name="categ_id" ref="hr_expense.cat_expense"/>
<field name="hr_expense_ok" eval="True" />
</record>
<record id="product_product_expense_hotel" model="product.product">
<field name="list_price">1.0</field>
<field name="standard_price">1.0</field>
<field name="uom_id" ref="product.product_uom_unit"/>
<field name="uom_po_id" ref="product.product_uom_unit"/>
<record id="hotel_rent" model="product.product">
<field name="list_price">400.0</field>
<field name="type">service</field>
<field name="name">Hotel Accommodation</field>
<field name="default_code">HA0</field>
<field name="categ_id" ref="product.cat2"/>
<field name="categ_id" ref="hr_expense.cat_expense"/>
<field name="hr_expense_ok" eval="True" />
</record>
<record id="hr_expense_expense_septemberexpenses0" model="hr.expense.expense">
<field name="currency_id" ref="base.EUR"/>
<field name="employee_id" ref="hr.employee1"/>
<field name="user_id" ref="base.user_root"/>
<field name="name">May Expenses</field>
<field name="company_id" ref="base.main_company"/>
<field name="date" eval="time.strftime('%Y-%m-03')"/>
<field name="state">draft</field>
<record id="sep_expenses" model="hr.expense.expense">
<field name="employee_id" ref="hr.employee3"/>
<field name="name">September Expenses</field>
<field name="date" eval="time.strftime('%Y-09-28')"/>
</record>
<record id="hr_expense_line_travelbycarcustomerseagatedouble0" model="hr.expense.line">
<record id="travel_by_air_sep" model="hr.expense.line">
<field name="name">Travel by Air</field>
<field name="date_value" eval="time.strftime('%Y-%m-03')"/>
<field name="date_value" eval="time.strftime('%Y-09-03')"/>
<field name="analytic_account" ref="account.analytic_consultancy"/>
<field name="product_id" ref="product_product_expense_air"/>
<field model="hr.expense.expense" name="expense_id" search="[('name', '=', u'May Expenses')]"/>
<field name="product_id" ref="air_ticket"/>
<field name="expense_id" ref="sep_expenses"/>
<field eval="700.0" name="unit_amount"/>
<field name="uom_id" ref="product.product_uom_unit"/>
<field eval="1.0" name="unit_quantity"/>
</record>
<record id="hr_expense_line_basicpcserverforseagate0" model="hr.expense.line">
<field name="name">Basic PC - Server for Seagate</field>
<field name="date_value" eval="time.strftime('%Y-%m-03')"/>
<field name="analytic_account" ref="account.analytic_seagate_p2"/>
<field name="product_id" ref="product.product_product_pc4"/>
<field model="hr.expense.expense" name="expense_id" search="[('name', '=', u'May Expenses')]"/>
<field eval="1200.0" name="unit_amount"/>
<field name="uom_id" ref="product.product_uom_unit"/>
<field eval="1.0" name="unit_quantity"/>
</record>
</data>
<data noupdate="1">
<record id="hr_expense_expense_septemberexpenses1" model="hr.expense.expense">
<field name="currency_id" ref="base.EUR"/>
<field name="employee_id" ref="hr.employee1"/>
<field name="user_id" ref="base.user_root"/>
<field name="name">Travel Expenses</field>
<field name="company_id" ref="base.main_company"/>
<field name="date" eval="time.strftime('%Y-%m-20')"/>
<field name="state">draft</field>
</record>
<record id="hr_expense_line_hotelexpensesthymbra0" model="hr.expense.line">
<record id="hotel_bill_sep" model="hr.expense.line">
<field name="name">Hotel Expenses - Thymbra</field>
<field name="date_value" eval="time.strftime('%Y-%m-03')"/>
<field name="date_value" eval="time.strftime('%Y-09-20')"/>
<field name="analytic_account" ref="account.analytic_thymbra"/>
<field name="product_id" ref="product_product_expense_hotel"/>
<field model="hr.expense.expense" name="expense_id" search="[('name', '=', u'Travel Expenses')]"/>
<field name="product_id" ref="hotel_rent"/>
<field name="expense_id" ref="sep_expenses"/>
<field eval="400.0" name="unit_amount"/>
<field name="uom_id" ref="product.product_uom_unit"/>
<field eval="5.0" name="unit_quantity"/>
</record>
<record id="hr_expense_line_car_travel" model="hr.expense.line">
<record id="car_travel_sep" model="hr.expense.line">
<field name="name">Bruxelles - Paris</field>
<field name="date_value" eval="time.strftime('%Y-%m-03')"/>
<field name="date_value" eval="time.strftime('%Y-09-15')"/>
<field name="analytic_account" ref="account.analytic_thymbra"/>
<field name="product_id" ref="product_product_expense_car"/>
<field model="hr.expense.expense" name="expense_id" search="[('name', '=', u'Travel Expenses')]"/>
<field name="product_id" ref="car_travel"/>
<field name="expense_id" ref="sep_expenses"/>
<field eval="0.30" name="unit_amount"/>
<field name="uom_id" ref="product.product_uom_km"/>
<field eval="622.0" name="unit_quantity"/>
</record>
</data>
</openerp>

View File

@ -1,71 +0,0 @@
-
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)

View File

@ -0,0 +1,46 @@
-
In Order to test process of "Employee Expenses".
-
I confirm "Expense Bill of September" of one employee of Marketing Department.
-
!workflow {model: hr.expense.expense, action: confirm, ref: sep_expenses}
-
I check state of expense after confirmed
-
!assert {model: hr.expense.expense, id: sep_expenses}:
- state == 'confirm'
-
I accept this expense.
-
!workflow {model: hr.expense.expense, action: validate, ref: sep_expenses}
-
I make Invoice for the expense.
-
!python {model: hr.expense.expense}: |
self.invoice(cr, uid, [ref('sep_expenses')])
-
I check invoice details after invoiced.
-
!python {model: hr.expense.expense}: |
sep_expenses = self.browse(cr, uid, ref("sep_expenses"), context=context)
assert sep_expenses.state == 'invoiced', "Expense should be in 'Invoiced' state."
assert sep_expenses.invoice_id, "Expense should have link of Invoice."
-
I paid the expense
-
!python {model: hr.expense.expense}: |
self.expense_paid(cr, uid, [ref('sep_expenses')])
-
I check the expense after paid.
-
!assert {model: hr.expense.expense, id: sep_expenses}:
- state == 'paid'
-
I print this expense
-
!python {model: hr.expense.expense}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.hr.expense').create(cr, uid, [ref('hr_expense.sep_expenses')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'hr_expense-report.'+format), 'wb+').write(data)