[IMP] hr_improvement : Added 'Open Receipt' button to open the receipt in 'receipted' state.

bzr revid: mdi@tinyerp.com-20120713123952-gr48p943v6rjon57
This commit is contained in:
Divyesh Makwana (Open ERP) 2012-07-13 18:09:52 +05:30
parent 0fee0b9527
commit e068186c17
2 changed files with 20 additions and 0 deletions

View File

@ -212,6 +212,25 @@ class hr_expense_expense(osv.osv):
self.write(cr, uid, [exp.id], {'voucher_id': voucher_id, 'state': 'receipted'}, context=context)
res = voucher_id
return res
def action_view_receipt(self, cr, uid, ids, context=None):
'''
This function returns an action that display existing receipt of given expense ids.
'''
voucher_id = self.browse(cr, uid, ids[0], context=context).voucher_id.id
res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_voucher', 'view_purchase_receipt_form')
result = {
'name': _('Expense Receipt'),
'view_type': 'form',
'view_mode': 'form',
'view_id': res and res[1] or False,
'res_model': 'account.voucher',
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'current',
'res_id': voucher_id,
}
return result
hr_expense_expense()

View File

@ -69,6 +69,7 @@
<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="object" 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="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"}'/>
</header>