[IMP] hr_expense : After the confirmation of the expense, the button should create a purchase receipt and confirmed it. It must creates the accounting entries exactly as the current invoice does.
bzr revid: mdi@tinyerp.com-20120717104214-pwypgr6d17ji4s4q
This commit is contained in:
parent
7ea31c56f7
commit
bb7df4dcc5
|
@ -34,7 +34,6 @@ The whole workflow is implemented:
|
|||
* Confirmation of the sheet by the employee
|
||||
* Validation by his manager
|
||||
* Validation by the accountant and receipt creation
|
||||
* Payment of the receipt to the employee
|
||||
|
||||
This module also uses the analytic accounting and is compatible with
|
||||
the invoice on timesheet module so that you will be able to automatically
|
||||
|
|
|
@ -67,7 +67,7 @@ class hr_expense_expense(osv.osv):
|
|||
'name': fields.char('Description', size=128, required=True),
|
||||
'id': fields.integer('Sheet ID', readonly=True),
|
||||
'date': fields.date('Date', select=True),
|
||||
'journal_id': fields.many2one('account.journal', 'Force Journal', help = "The journal used when the expense is receipted."),
|
||||
'journal_id': fields.many2one('account.journal', 'Force Journal', help = "The journal used when the expense is done."),
|
||||
'employee_id': fields.many2one('hr.employee', "Employee", required=True),
|
||||
'user_id': fields.many2one('res.users', 'User', required=True),
|
||||
'date_confirm': fields.date('Confirmation Date', select=True, help = "Date of the confirmation of the sheet expense. It's filled when the button Confirm is pressed."),
|
||||
|
@ -86,11 +86,10 @@ class hr_expense_expense(osv.osv):
|
|||
('cancelled', 'Refused'),
|
||||
('confirm', 'Waiting Approval'),
|
||||
('accepted', 'Approved'),
|
||||
('receipted', 'Waiting Reimbursement'),
|
||||
('paid', 'Reimbursed')
|
||||
('done', 'Done'),
|
||||
],
|
||||
'Status', readonly=True, help='When the expense request is created the status is \'Draft\'.\n It is confirmed by the user and request is sent to admin, the status is \'Waiting Confirmation\'.\
|
||||
\nIf the admin accepts it, the status is \'Accepted\'.\n If a receipt is made for the expense request, the status is \'Waiting Reimbursement\'.\n If the expense is paid to user, the status is \'Reimbursed\'.'),
|
||||
\nIf the admin accepts it, the status is \'Accepted\'.\n If a receipt is made for the expense request, the status is \'Done\'.'),
|
||||
}
|
||||
_defaults = {
|
||||
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'hr.employee', context=c),
|
||||
|
@ -130,10 +129,6 @@ class hr_expense_expense(osv.osv):
|
|||
self.write(cr, uid, ids, {'state':'cancelled'})
|
||||
return True
|
||||
|
||||
def expense_paid(self, cr, uid, ids, *args):
|
||||
self.write(cr, uid, ids, {'state':'paid'})
|
||||
return True
|
||||
|
||||
def action_receipt_create(self, cr, uid, ids, context=None):
|
||||
property_obj = self.pool.get('ir.property')
|
||||
sequence_obj = self.pool.get('ir.sequence')
|
||||
|
@ -192,7 +187,7 @@ class hr_expense_expense(osv.osv):
|
|||
account_journal.write(cr, uid, [journal.id], {'analytic_journal_id': analytic_journal_ids[0]}, context=context)
|
||||
voucher_id = voucher_obj.create(cr, uid, voucher, context=context)
|
||||
wkf_service.trg_validate(uid, 'account.voucher', voucher_id, 'proforma_voucher', cr)
|
||||
self.write(cr, uid, [exp.id], {'voucher_id': voucher_id, 'state': 'receipted'}, context=context)
|
||||
self.write(cr, uid, [exp.id], {'voucher_id': voucher_id, 'state': 'done'}, context=context)
|
||||
return True
|
||||
|
||||
def action_view_receipt(self, cr, uid, ids, context=None):
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
<field name="model">hr.expense.expense</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree colors="blue:state == 'draft';black:state in ('confirm','accepted','receipted','paid');gray:state == 'cancelled'" string="Expenses" editable="top">
|
||||
<tree colors="blue:state == 'draft';black:state in ('confirm','accepted','done');gray:state == 'cancelled'" string="Expenses" editable="top">
|
||||
<field name="employee_id"/>
|
||||
<field name="date"/>
|
||||
<field name="department_id"/>
|
||||
|
@ -68,10 +68,10 @@
|
|||
<button name="confirm" states="draft" string="Submit to Manager" type="workflow" class="oe_highlight"/>
|
||||
<button name="validate" states="confirm" string="Approve" type="workflow" groups="base.group_hr_user" class="oe_highlight"/>
|
||||
<button name="draft" states="confirm,cancelled" string="Set to Draft" type="workflow" groups="base.group_hr_user" />
|
||||
<button name="receipt" states="accepted" string="Issue Receipt" type="workflow" groups="base.group_hr_user" class="oe_highlight"/>
|
||||
<button name="action_view_receipt" states="receipted" string="Open Receipt" type="object" class="oe_highlight"/>
|
||||
<button name="done" states="accepted" string="Issue Receipt" type="workflow" groups="base.group_hr_user" class="oe_highlight"/>
|
||||
<button name="action_view_receipt" states="done" string="Open Receipt" type="object" class="oe_highlight"/>
|
||||
<button name="refuse" states="confirm,accepted" string="Refuse" type="workflow" groups="base.group_hr_user" />
|
||||
<field name="state" widget="statusbar" statusbar_visible="draft,confirm,accepted" statusbar_colors='{"confirm":"blue","cancelled":"red"}'/>
|
||||
<field name="state" widget="statusbar" statusbar_visible="draft,confirm,accepted,done" statusbar_colors='{"confirm":"blue","cancelled":"red"}'/>
|
||||
</header>
|
||||
<sheet>
|
||||
<group>
|
||||
|
|
|
@ -32,14 +32,6 @@
|
|||
<field name="action">expense_accept()</field>
|
||||
</record>
|
||||
|
||||
<record id="act_paid" model="workflow.activity">
|
||||
<field name="wkf_id" ref="wkf_expenses"/>
|
||||
<field name="name">paid</field>
|
||||
<field name="kind">function</field>
|
||||
<field name="action">expense_paid()</field>
|
||||
<field name="flow_stop">True</field>
|
||||
</record>
|
||||
|
||||
<record id="act_refused" model="workflow.activity">
|
||||
<field name="wkf_id" ref="wkf_expenses"/>
|
||||
<field name="name">refused</field>
|
||||
|
@ -47,9 +39,9 @@
|
|||
<field name="action">expense_canceled()</field>
|
||||
</record>
|
||||
|
||||
<record id="act_receipt" model="workflow.activity">
|
||||
<record id="act_done" model="workflow.activity">
|
||||
<field name="wkf_id" ref="wkf_expenses"/>
|
||||
<field name="name">receipt</field>
|
||||
<field name="name">done</field>
|
||||
<field name="kind">function</field>
|
||||
<field name="action">action_receipt_create()</field>
|
||||
</record>
|
||||
|
@ -90,15 +82,8 @@
|
|||
|
||||
<record id="t8" model="workflow.transition">
|
||||
<field name="act_from" ref="act_accepted"/>
|
||||
<field name="act_to" ref="act_receipt"/>
|
||||
<field name="signal">receipt</field>
|
||||
<field name="group_id" ref="base.group_hr_user"/>
|
||||
</record>
|
||||
|
||||
<record id="t9" model="workflow.transition">
|
||||
<field name="act_from" ref="act_receipt"/>
|
||||
<field name="act_to" ref="act_paid"/>
|
||||
<field name="signal">paid</field>
|
||||
<field name="act_to" ref="act_done"/>
|
||||
<field name="signal">done</field>
|
||||
<field name="group_id" ref="base.group_hr_user"/>
|
||||
</record>
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ class hr_expense_report(osv.osv):
|
|||
'product_id':fields.many2one('product.product', 'Product', readonly=True),
|
||||
'journal_id': fields.many2one('account.journal', 'Force Journal', readonly=True),
|
||||
'product_qty':fields.float('Qty', readonly=True),
|
||||
'receipted':fields.integer('# of Receipted Lines', readonly=True),
|
||||
'employee_id': fields.many2one('hr.employee', "Employee's Name", readonly=True),
|
||||
'date_confirm': fields.date('Confirmation Date', readonly=True),
|
||||
'date_valid': fields.date('Validation Date', readonly=True),
|
||||
|
@ -60,8 +59,7 @@ class hr_expense_report(osv.osv):
|
|||
('draft', 'Draft'),
|
||||
('confirm', 'Waiting confirmation'),
|
||||
('accepted', 'Accepted'),
|
||||
('receipted', 'Receipted'),
|
||||
('paid', 'Reimbursed'),
|
||||
('done', 'Done'),
|
||||
('cancelled', 'Cancelled')],
|
||||
'Status', readonly=True),
|
||||
}
|
||||
|
@ -79,7 +77,6 @@ class hr_expense_report(osv.osv):
|
|||
to_date(to_char(s.date_confirm, 'dd-MM-YYYY'),'dd-MM-YYYY') as date_confirm,
|
||||
to_date(to_char(s.date_valid, 'dd-MM-YYYY'),'dd-MM-YYYY') as date_valid,
|
||||
s.voucher_id,
|
||||
count(s.voucher_id) as receipted,
|
||||
s.user_valid as user_id,
|
||||
s.department_id,
|
||||
to_char(date_trunc('day',s.create_date), 'YYYY') as year,
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<field name="model">hr.expense.report</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree colors="blue:state == 'draft';black:state in ('confirm','accepted','receipted','paid');gray:state == 'cancelled'" string="Expenses Analysis">
|
||||
<tree colors="blue:state == 'draft';black:state in ('confirm','accepted','done');gray:state == 'cancelled'" string="Expenses Analysis">
|
||||
<field name="employee_id" invisible="1"/>
|
||||
<field name="user_id" invisible="1"/>
|
||||
<field name="year" invisible="1"/>
|
||||
|
@ -23,7 +23,6 @@
|
|||
<field name="state" invisible="1"/>
|
||||
<field name="nbr" sum="# of Lines"/>
|
||||
<field name="no_of_products" sum="# of Products"/>
|
||||
<field name="receipted" sum="Total Receipted Lines"/>
|
||||
<field name="price_average" avg="Average Price"/>
|
||||
<field name="price_total" sum="Total Price"/>
|
||||
<field name="delay_confirm"/>
|
||||
|
@ -56,8 +55,6 @@
|
|||
help = "Confirm Expenses"/>
|
||||
<filter string="Approved" icon="terp-check" domain="[('state','=','accepted')]"
|
||||
help = "Approved Expenses"/>
|
||||
<filter string="Receipted" icon="terp-dolar" domain="[('state','in', ('receipted', 'paid'))]"
|
||||
help = "Receipted Expenses"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="employee_id"/>
|
||||
<field name="department_id"/>
|
||||
|
|
|
@ -26,22 +26,12 @@
|
|||
-
|
||||
!python {model: hr.expense.expense}: |
|
||||
sep_expenses = self.browse(cr, uid, ref("sep_expenses"), context=context)
|
||||
assert sep_expenses.state == 'receipted', "Expense should be in 'Waiting Reimbursement' state."
|
||||
assert sep_expenses.state == 'done', "Expense should be in 'Done' state."
|
||||
assert sep_expenses.voucher_id.name == sep_expenses.name,"Receipt name is not correspond with expense name."
|
||||
assert sep_expenses.voucher_id.type == 'purchase', "Receipt type is not purchase receipt."
|
||||
assert sep_expenses.voucher_id.amount == sep_expenses.amount,"Receipt total amount is not correspond with expense total."
|
||||
assert len(sep_expenses.voucher_id.line_dr_ids) == len(sep_expenses.line_ids),"Lines of Receipt and expense line are not correspond."
|
||||
|
||||
-
|
||||
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.
|
||||
-
|
||||
|
|
Loading…
Reference in New Issue