diff --git a/addons/hr_expense/__openerp__.py b/addons/hr_expense/__openerp__.py index 7d11b0912bc..1114cf3c18a 100644 --- a/addons/hr_expense/__openerp__.py +++ b/addons/hr_expense/__openerp__.py @@ -63,7 +63,8 @@ re-invoice your customer's expenses if your work by project. 'hr_expense_demo.xml', ], 'test': [ - 'test/confirm2heldinvoiced.yml', + 'test/expense_process.yml', + 'test/expense_demo.yml', ], 'installable': True, 'active': False, diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index 478b8120935..572da086e8d 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -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, diff --git a/addons/hr_expense/hr_expense_data.xml b/addons/hr_expense/hr_expense_data.xml index 9660dbb2543..0e940c74cc0 100644 --- a/addons/hr_expense/hr_expense_data.xml +++ b/addons/hr_expense/hr_expense_data.xml @@ -8,18 +8,6 @@ Expenses - - - 0.32 - 0.32 - - - consu - Travel Expenses - TRA - - - - \ No newline at end of file + diff --git a/addons/hr_expense/hr_expense_demo.xml b/addons/hr_expense/hr_expense_demo.xml index 80c9cd66694..7e079b21e14 100644 --- a/addons/hr_expense/hr_expense_demo.xml +++ b/addons/hr_expense/hr_expense_demo.xml @@ -1,96 +1,76 @@ - + - - 1.0 - 1.0 - - + + + + + + 0.32 + service + Car Travel Expenses + CarTRA + + + + + + 700.0 service Air Ticket AT - + - - 1.0 - 1.0 - - + + 400.0 service Hotel Accommodation HA0 - + - - - - - May Expenses - - - draft + + + September Expenses + - + Travel by Air - + - - + + - - Basic PC - Server for Seagate - - - - - - - - - - - - - - - - - Travel Expenses - - - draft - - - + Hotel Expenses - Thymbra - + - - + + - + Bruxelles - Paris - + - - + + + diff --git a/addons/hr_expense/test/confirm2heldinvoiced.yml b/addons/hr_expense/test/confirm2heldinvoiced.yml deleted file mode 100644 index 5574317de0d..00000000000 --- a/addons/hr_expense/test/confirm2heldinvoiced.yml +++ /dev/null @@ -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) \ No newline at end of file diff --git a/addons/hr_expense/test/expense_demo.yml b/addons/hr_expense/test/expense_demo.yml new file mode 100644 index 00000000000..6364e44d9bd --- /dev/null +++ b/addons/hr_expense/test/expense_demo.yml @@ -0,0 +1,11 @@ +- + !record {model: hr.expense.expense, id: hr.employee3, view: False}: + employee_id: 'hr.employee3' + name : 'Antoine Philippe' +- + !record {model: product.product, id: car_travel, view: False}: + hr_expense_ok: 'True +- + !record {model: hr.expense.line, id: expense_line, view: False}: + product_id: 'car_travel' + name: 'Car Travel Expenses' \ No newline at end of file diff --git a/addons/hr_expense/test/expense_process.yml b/addons/hr_expense/test/expense_process.yml new file mode 100644 index 00000000000..654b28bde5e --- /dev/null +++ b/addons/hr_expense/test/expense_process.yml @@ -0,0 +1,50 @@ +- + In Order to test process of "Employee Expenses". +- + I confirm "Expense Bill of September" for 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." + assert sep_expenses.invoice_id.currency_id == sep_expenses.currency_id,"Invoice currency is not correspond with supplier invoice currency" + assert sep_expenses.invoice_id.origin == sep_expenses.name,"Invoice origin is not correspond with supplier invoice" + assert sep_expenses.invoice_id.type == 'in_invoice', "Invoice type is not supplier invoice" + assert sep_expenses.invoice_id.amount_total == sep_expenses.amount,"Invoice total amount is not correspond with supplier invoice total" + assert len(sep_expenses.invoice_id.invoice_line) == len(sep_expenses.line_ids),"Lines of Invoice and supplier invoice Line are not correspond" +- + 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) \ No newline at end of file