[MERGE] merge atp branch for hr_expense YAML task
authormra (Open ERP) <mra@tinyerp.com>
Fri, 28 May 2010 10:10:53 +0000 (15:40 +0530)
committermra (Open ERP) <mra@tinyerp.com>
Fri, 28 May 2010 10:10:53 +0000 (15:40 +0530)
bzr revid: mra@tinyerp.com-20100528101053-iyu7q6pctfx6envn

1  2 
addons/hr_expense/test/test_hr_expense.yml

index 0000000,82597ad..70e2bfb
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,108 +1,107 @@@
+ - |
+   In order to test hr_expenses for OpenERP, I create expense for employee and manage employee's expenses.
 -- | 
++- |
+   Creating  unit of measure category "Working Time".
 -- 
++-
+   !record {model: product.uom.categ, id: product_uom_categ_workingtime0}:
 -    name: Working Time.     
 -  
++    name: Working Time.
++
+ - |
 -  Given that I have employee "employee1" and that address. 
 -- 
++  Given that I have employee "Marc John" and his address.
++-
+   !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     
 -- | 
 -  Creating a product  "travel" and select uom "Hour" and category "Working Time". 
 -- 
++    rounding: 0.01
++- |
++  Creating a product  "travel" and select uom "Hour" and category "Working Time".
++-
+   !record {model: product.product, id: product_product_travel0}:
+     categ_id: product.product_category_services
+     cost_method: standard
+     hr_expense_ok: 1
+     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
 - 
++
+ - |
 -  Now I create Expense "September Expenses" for  employee1.and select product "travel". 
 -- 
++  Now I create Expense "September Expenses" for  Marc John.And select product "travel".
++-
+   !record {model: hr.expense.expense, id: hr_expense_expense_september0}:
+     company_id: base.main_company
+     currency_id: base.EUR
+     date: '2010-05-05'
+     employee_id: hr.employee1
+     name: September Expenses
+     line_ids:
+       - date_value: '2010-05-27'
+         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 expenses on "draft" state.
+ -
+   !assert {model: hr.expense.expense, id: hr_expense_expense_september0}:
+     - state == 'draft'
+ - |
+   I confirm this expenses by click on "Confirm" button.
 -- 
 -  !workflow {model: hr.expense.expense, action: confirm, ref: hr_expense_expense_september0}     
 -    
++-
++  !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 expenses by click on "Invoice" button.
 -- 
++-
+   !workflow {model: hr.expense.expense, action: invoice, ref: hr_expense_expense_september0}
 -  
++
+ - |
+   I check that state is "Invoiced"
+ -
+   !assert {model: hr.expense.expense, id: hr_expense_expense_september0}:
+     - state == 'invoiced'
+ - |
+   Now I check that Invoice is created for that expenses.
+ -
+   !python {model: hr.expense.expense}: |
+     exp = self.browse(cr, uid, [ref('hr_expense_expense_september0')])[0]
+     invoice_obj = self.pool.get('account.invoice')
 -    invoice_ids = invoice_obj.search(cr, uid, [('partner_id', '=', exp.employee_id.address_id.partner_id.id)]) 
++    invoice_ids = invoice_obj.search(cr, uid, [('partner_id', '=', exp.employee_id.address_id.partner_id.id)])
+     invoice_id = invoice_obj.browse(cr, uid, invoice_ids)[0]
 -    
++
+     for invoice in invoice_id.invoice_line:
+       product = invoice.product_id.id
 -      
++
+     for line  in exp.line_ids:
+       product_exp = line.product_id.id
 -    assert product == product_exp  
 -    assert exp.id == invoice_id.id 
 -    
 -  
++    assert product == product_exp
++    assert exp.id == invoice_id.id
++