From eb9c03282cb17db7fb85d6905d39e1c3d2cc0203 Mon Sep 17 00:00:00 2001
From: Saurang Suthar
Date: Fri, 23 Nov 2012 16:16:18 +0530
Subject: [PATCH] [IMP]sale:added new button Create & View Invoice for creating
and view invoice
bzr revid: ssu@tinyerp.com-20121123104618-jxs2vk8huakuptua
---
addons/sale/wizard/sale_line_invoice.py | 23 ++++++++++++++++++++++-
addons/sale/wizard/sale_line_invoice.xml | 2 ++
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/addons/sale/wizard/sale_line_invoice.py b/addons/sale/wizard/sale_line_invoice.py
index f442cbe0a8e..4caace0f9bf 100644
--- a/addons/sale/wizard/sale_line_invoice.py
+++ b/addons/sale/wizard/sale_line_invoice.py
@@ -109,9 +109,30 @@ class sale_order_line_make_invoice(osv.osv_memory):
if not invoices:
raise osv.except_osv(_('Warning!'), _('Invoice cannot be created for this Sales Order Line due to one of the following reasons:\n1.The state of this sales order line is either "draft" or "cancel"!\n2.The Sales Order Line is Invoiced!'))
-
+ if context.get('open_invoices', False):
+ return self.open_invoices( cr, uid, ids, res, context=context)
return {'type': 'ir.actions.act_window_close'}
+ def open_invoices(self, cr, uid, ids, invoice_ids, context=None):
+ """ open a view on one of the given invoice_ids """
+ ir_model_data = self.pool.get('ir.model.data')
+ form_res = ir_model_data.get_object_reference(cr, uid, 'account', 'invoice_form')
+ form_id = form_res and form_res[1] or False
+ tree_res = ir_model_data.get_object_reference(cr, uid, 'account', 'invoice_tree')
+ tree_id = tree_res and tree_res[1] or False
+
+ return {
+ 'name': _('Advance Invoice'),
+ 'view_type': 'form',
+ 'view_mode': 'form,tree',
+ 'res_model': 'account.invoice',
+ 'res_id': invoice_ids,
+ 'view_id': False,
+ 'views': [(form_id, 'form'), (tree_id, 'tree')],
+ 'context': {'type': 'out_invoice'},
+ 'type': 'ir.actions.act_window',
+ }
+
sale_order_line_make_invoice()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/sale/wizard/sale_line_invoice.xml b/addons/sale/wizard/sale_line_invoice.xml
index 49b93edb40d..6144ff489f4 100644
--- a/addons/sale/wizard/sale_line_invoice.xml
+++ b/addons/sale/wizard/sale_line_invoice.xml
@@ -14,6 +14,8 @@
or a fixed price (for advances) directly from the sale order form if you prefer.