summaryrefslogtreecommitdiff
path: root/addons/hr_expense
diff options
context:
space:
mode:
authorHarry (OpenERP) <hmo@tinyerp.com>2011-12-14 17:59:24 +0530
committerHarry (OpenERP) <hmo@tinyerp.com>2011-12-14 17:59:24 +0530
commit092f97b32b35af6a40b9d2ae70c3159da2fb235f (patch)
tree2974d3719af9338cd0b1814da900d7e9ca8d4779 /addons/hr_expense
parent593f5f571bbc49673975afc405e9345ef3457b92 (diff)
parente36dc8c5e3ca3da1474747bae5ec87fea19b23b8 (diff)
[MERGE] merged with trunk-development-branch
bzr revid: hmo@tinyerp.com-20111214122924-izzibrz1yz67rt7g
Diffstat (limited to 'addons/hr_expense')
-rw-r--r--addons/hr_expense/__openerp__.py8
-rw-r--r--addons/hr_expense/board_hr_expense_view.xml2
-rw-r--r--addons/hr_expense/hr_expense.py1
-rw-r--r--addons/hr_expense/hr_expense_data.xml14
-rw-r--r--addons/hr_expense/hr_expense_demo.xml105
-rw-r--r--addons/hr_expense/hr_expense_view.xml2
-rw-r--r--addons/hr_expense/security/ir.model.access.csv46
-rw-r--r--addons/hr_expense/test/expense_demo.yml11
-rw-r--r--addons/hr_expense/test/expense_process.yml60
-rw-r--r--addons/hr_expense/test/hr_expense_report.yml8
-rw-r--r--addons/hr_expense/test/test_hr_expense.yml121
11 files changed, 151 insertions, 227 deletions
diff --git a/addons/hr_expense/__openerp__.py b/addons/hr_expense/__openerp__.py
index 4a22f00e076..4e91155442b 100644
--- a/addons/hr_expense/__openerp__.py
+++ b/addons/hr_expense/__openerp__.py
@@ -21,7 +21,7 @@
{
- 'name': 'Expenses',
+ 'name': 'Expenses Management',
'version': '1.0',
'category': 'Human Resources',
'complexity': "easy",
@@ -62,11 +62,13 @@ 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/expense_demo.yml',
+ 'test/expense_process.yml',
],
'installable': True,
'active': False,
'certificate': '0062479841789',
+ 'application': True,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/hr_expense/board_hr_expense_view.xml b/addons/hr_expense/board_hr_expense_view.xml
index d9c80d6f755..3383f734f7d 100644
--- a/addons/hr_expense/board_hr_expense_view.xml
+++ b/addons/hr_expense/board_hr_expense_view.xml
@@ -17,7 +17,7 @@
<field name="inherit_id" ref="hr.board_hr_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
- <xpath expr="/form/board/column" position="inside">
+ <xpath expr="/form/board/column[1]" position="inside">
<action name="%(action_my_expense)d" string="My Expenses"/>
</xpath>
</field>
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 @@
<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> \ No newline at end of file
+</openerp>
diff --git a/addons/hr_expense/hr_expense_demo.xml b/addons/hr_expense/hr_expense_demo.xml
index 80c9cd66694..8912dfb09de 100644
--- a/addons/hr_expense/hr_expense_demo.xml
+++ b/addons/hr_expense/hr_expense_demo.xml
@@ -2,95 +2,88 @@
<openerp>
<data noupdate="1">
- <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.employee4" 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="expenses0" model="hr.expense.expense">
+ <field name="name">Expenses</field>
+ <field name="date" eval="time.strftime('%Y-08-25')"/>
</record>
-
- <record id="hr_expense_line_travelbycarcustomerseagatedouble0" model="hr.expense.line">
- <field name="name">Travel by Air</field>
- <field name="date_value" eval="time.strftime('%Y-%m-03')"/>
+ <record id="expenses_line0" model="hr.expense.line">
+ <field name="name">Travel Expenses</field>
+ <field name="date_value" eval="time.strftime('%Y-08-10')"/>
<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 eval="700.0" name="unit_amount"/>
+ <field name="expense_id" ref="expenses0"/>
+ <field eval="200.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 id="sep_expenses" model="hr.expense.expense">
+ <field name="employee_id" ref="hr.employee4"/>
+ <field name="name">September Expenses</field>
+ <field name="date" eval="time.strftime('%Y-09-28')"/>
</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 id="travel_by_air_sep" model="hr.expense.line">
+ <field name="name">Travel by Air</field>
+ <field name="date_value" eval="time.strftime('%Y-09-03')"/>
+ <field name="analytic_account" ref="account.analytic_consultancy"/>
+ <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_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>
diff --git a/addons/hr_expense/hr_expense_view.xml b/addons/hr_expense/hr_expense_view.xml
index 786dc6beee2..cf884af4250 100644
--- a/addons/hr_expense/hr_expense_view.xml
+++ b/addons/hr_expense/hr_expense_view.xml
@@ -30,8 +30,6 @@
<field name="employee_id"/>
<field name="date"/>
<field name="user_id" invisible="1"/>
- <field name="department_id" groups="base.group_extended"/>
- <field name="ref"/>
<field name="name"/>
<field name="amount"/>
<field name="state"/>
diff --git a/addons/hr_expense/security/ir.model.access.csv b/addons/hr_expense/security/ir.model.access.csv
index 674b06304d2..0455302319e 100644
--- a/addons/hr_expense/security/ir.model.access.csv
+++ b/addons/hr_expense/security/ir.model.access.csv
@@ -1,23 +1,23 @@
-"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
-"access_hr_expense_expense_user","hr.expense.expense.user","model_hr_expense_expense","base.group_hr_user",1,1,1,1
-"access_hr_expense_expense_employee","hr.expense.expense.employee","model_hr_expense_expense","base.group_user",1,1,1,1
-"access_hr_expense_line_user","hr.expense.line.user","model_hr_expense_line","base.group_hr_user",1,1,1,1
-"access_hr_expense_line_employee","hr.expense.line.employee","model_hr_expense_line","base.group_user",1,1,1,1
-"access_hr_expense_report_manager","hr.expense.report.manager","model_hr_expense_report","base.group_hr_manager",1,1,1,1
-"access_product_product_hr_expense_user","product.product.hr.expense.user","product.model_product_product","base.group_hr_user",1,1,1,1
-"access_product_template_hr_expense_user","product.template.hr.expense.user","product.model_product_template","base.group_hr_user",1,1,1,1
-"access_product_uom_hr_expense_user","product.uom.hr.expense.user","product.model_product_uom","base.group_hr_user",1,1,1,1
-"access_product_price_type_user","product.price.type.user","product.model_product_price_type","base.group_hr_user",1,1,1,1
-"access_account_journal_user","account.journal.user","account.model_account_journal","base.group_hr_user",1,1,1,1
-"access_account_invoice_user","account.invoice.user","account.model_account_invoice","base.group_hr_user",1,1,1,1
-"access_account_invoice_line_user","account.invoice.line.user","account.model_account_invoice_line","base.group_hr_user",1,1,1,1
-"access_account_analytic_journal_user","account.ianalytic.journal.user","account.model_account_analytic_journal","base.group_hr_user",1,1,1,1
-"access_account_invoice_tax_user","account.invoice.tax.user","account.model_account_invoice_tax","base.group_hr_user",1,1,1,1
-"access_account_period_user","account.period.user","account.model_account_period","base.group_hr_user",1,1,1,1
-"access_account_fiscalyear_user","account.fiscalyear.user","account.model_account_fiscalyear","base.group_hr_user",1,1,1,1
-"access_account_move_user","account.move.user","account.model_account_move","base.group_hr_user",1,1,1,1
-"access_account_move_line_user","account.move.line.user","account.model_account_move_line","base.group_hr_user",1,1,1,1
-"access_account_analytic_line_user","account.ianalytic.line.user","account.model_account_analytic_line","base.group_hr_user",1,1,1,1
-"access_account_journal_period_manager","account.journal.period.manager","account.model_account_journal_period","base.group_hr_manager",1,1,1,1
-"hr.access_account_journal_view_hruser","account.journal.view hruser","account.model_account_journal_view","base.group_hr_user",1,0,0,0
-"hr.access_account_journal_column_hruser","account.journal.column hruser","account.model_account_journal_column","base.group_hr_user",1,0,0,0
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+access_hr_expense_expense_user,hr.expense.expense.user,model_hr_expense_expense,base.group_hr_user,1,1,1,1
+access_hr_expense_expense_employee,hr.expense.expense.employee,model_hr_expense_expense,base.group_user,1,1,1,1
+access_hr_expense_line_user,hr.expense.line.user,model_hr_expense_line,base.group_hr_user,1,1,1,1
+access_hr_expense_line_employee,hr.expense.line.employee,model_hr_expense_line,base.group_user,1,1,1,1
+access_hr_expense_report_manager,hr.expense.report.manager,model_hr_expense_report,base.group_hr_manager,1,1,1,1
+access_product_product_hr_expense_user,product.product.hr.expense.user,product.model_product_product,base.group_hr_user,1,1,1,1
+access_product_template_hr_expense_user,product.template.hr.expense.user,product.model_product_template,base.group_hr_user,1,1,1,1
+access_product_uom_hr_expense_user,product.uom.hr.expense.user,product.model_product_uom,base.group_hr_user,1,1,1,1
+access_product_price_type_user,product.price.type.user,product.model_product_price_type,base.group_hr_user,1,1,1,1
+access_account_journal_user,account.journal.user,account.model_account_journal,base.group_hr_user,1,1,1,1
+access_account_invoice_user,account.invoice.user,account.model_account_invoice,base.group_hr_user,1,1,1,1
+access_account_invoice_line_user,account.invoice.line.user,account.model_account_invoice_line,base.group_hr_user,1,1,1,1
+access_account_analytic_journal_user,account.ianalytic.journal.user,account.model_account_analytic_journal,base.group_hr_user,1,1,1,1
+access_account_invoice_tax_user,account.invoice.tax.user,account.model_account_invoice_tax,base.group_hr_user,1,1,1,1
+access_account_period_user,account.period.user,account.model_account_period,base.group_hr_user,1,1,1,1
+access_account_fiscalyear_user,account.fiscalyear.user,account.model_account_fiscalyear,base.group_hr_user,1,1,1,1
+access_account_move_user,account.move.user,account.model_account_move,base.group_hr_user,1,1,1,1
+access_account_move_line_user,account.move.line.user,account.model_account_move_line,base.group_hr_user,1,1,1,1
+access_account_analytic_line_user,account.ianalytic.line.user,account.model_account_analytic_line,base.group_hr_user,1,1,1,1
+access_account_journal_period_manager,account.journal.period.manager,account.model_account_journal_period,base.group_hr_manager,1,1,1,1
+hr.access_account_journal_view_hruser,account.journal.view hruser,account.model_account_journal_view,base.group_hr_user,1,0,0,0
+hr.access_account_journal_column_hruser,account.journal.column hruser,account.model_account_journal_column,base.group_hr_user,1,0,0,0
diff --git a/addons/hr_expense/test/expense_demo.yml b/addons/hr_expense/test/expense_demo.yml
new file mode 100644
index 00000000000..5b3cb0893d0
--- /dev/null
+++ b/addons/hr_expense/test/expense_demo.yml
@@ -0,0 +1,11 @@
+-
+ !record {model: hr.expense.expense, id: sep_expenses}:
+ employee_id: hr.employee4
+ name : 'John Smith'
+-
+ !record {model: product.product, id: car_travel}:
+ hr_expense_ok: 'True'
+-
+ !record {model: hr.expense.line, id: expense_line}:
+ product_id: car_travel
+ name: 'Car Travel Expenses'
diff --git a/addons/hr_expense/test/expense_process.yml b/addons/hr_expense/test/expense_process.yml
new file mode 100644
index 00000000000..5c8a9d53f7c
--- /dev/null
+++ b/addons/hr_expense/test/expense_process.yml
@@ -0,0 +1,60 @@
+-
+ In order to test the process of "Employee Expenses" by processing the expenses, I confirm Expense Bill of an employee for September month.
+-
+ !workflow {model: hr.expense.expense, action: confirm, ref: sep_expenses}
+-
+ I check that state is 'Confirm'.
+-
+ !assert {model: hr.expense.expense, id: sep_expenses, severity: error, string: Expense should be in Confirm state}:
+ - state == 'confirm'
+-
+ I approve the September expenses.
+-
+ !workflow {model: hr.expense.expense, action: validate, ref: sep_expenses}
+-
+ I check that state is 'Approved'
+-
+ !assert {model: hr.expense.expense, id: sep_expenses, severity: error, string: Expense should be in Approved state}:
+ - state == 'accepted'
+-
+ I make Invoice for the expense.
+-
+ !python {model: hr.expense.expense}: |
+ self.invoice(cr, uid, [ref('sep_expenses')])
+-
+ I check invoice details.
+-
+ !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"
+ #TODO: check invoice line details with Expenses lines
+-
+ I pay the expenses.
+-
+ !python {model: hr.expense.expense}: |
+ self.expense_paid(cr, uid, [ref('sep_expenses')])
+-
+ I check that state of expenses is 'Paid'.
+-
+ !assert {model: hr.expense.expense, id: sep_expenses, severity: error, string: Expense should be in Paid state}:
+ - state == 'paid'
+-
+ I duplicate the expenses and cancel duplicated.
+-
+ !python {model: hr.expense.expense}: |
+ duplicate_id = self.copy(cr, uid, ref('sep_expenses'), context=context)
+ self.expense_canceled(cr, uid, [duplicate_id])
+-
+ I print a report of the expenses.
+-
+ !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)
diff --git a/addons/hr_expense/test/hr_expense_report.yml b/addons/hr_expense/test/hr_expense_report.yml
deleted file mode 100644
index 4c81ceb5976..00000000000
--- a/addons/hr_expense/test/hr_expense_report.yml
+++ /dev/null
@@ -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) \ No newline at end of file
diff --git a/addons/hr_expense/test/test_hr_expense.yml b/addons/hr_expense/test/test_hr_expense.yml
deleted file mode 100644
index bd13529d645..00000000000
--- a/addons/hr_expense/test/test_hr_expense.yml
+++ /dev/null
@@ -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"
-