From bbbbe7c46b7a119fcb1daf1be844b306bea93d1c Mon Sep 17 00:00:00 2001 From: "Atul Patel (OpenERP)" Date: Fri, 27 Jul 2012 14:36:07 +0530 Subject: [PATCH] [FIX]: Chance manual_invoice method into sale_stock module. bzr revid: atp@tinyerp.com-20120727090607-w3y8jiy459z0iuok --- addons/sale/sale.py | 30 ------------------- addons/sale_stock/sale_stock.py | 35 ++++++++++++++++++++++- addons/sale_stock/sale_stock_workflow.xml | 4 --- 3 files changed, 34 insertions(+), 35 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index fca3fa992de..f458eb9e651 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -378,36 +378,6 @@ class sale_order(osv.osv): } return {'type': 'ir.actions.report.xml', 'report_name': 'sale.order', 'datas': datas, 'nodestroy': True} - def manual_invoice(self, cr, uid, ids, context=None): - """ create invoices for the given sale orders (ids), and open the form - view of one of the newly created invoices - """ - mod_obj = self.pool.get('ir.model.data') - wf_service = netsvc.LocalService("workflow") - - # create invoices through the sale orders' workflow - inv_ids0 = set(inv.id for sale in self.browse(cr, uid, ids, context) for inv in sale.invoice_ids) - for id in ids: - wf_service.trg_validate(uid, 'sale.order', id, 'manual_invoice', cr) - inv_ids1 = set(inv.id for sale in self.browse(cr, uid, ids, context) for inv in sale.invoice_ids) - # determine newly created invoices - new_inv_ids = list(inv_ids1 - inv_ids0) - - res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_form') - res_id = res and res[1] or False, - - return { - 'name': _('Customer Invoices'), - 'view_type': 'form', - 'view_mode': 'form', - 'view_id': [res_id], - 'res_model': 'account.invoice', - 'context': "{'type':'out_invoice'}", - 'type': 'ir.actions.act_window', - 'nodestroy': True, - 'target': 'current', - 'res_id': new_inv_ids and new_inv_ids[0] or False, - } def action_view_invoice(self, cr, uid, ids, context=None): ''' diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py index 3c43587a199..9f1ce3e590c 100644 --- a/addons/sale_stock/sale_stock.py +++ b/addons/sale_stock/sale_stock.py @@ -208,7 +208,40 @@ class sale_order(osv.osv): self.write(cr, uid, [o.id], {'state': 'progress', 'date_confirm': fields.date.context_today(self, cr, uid, context=context)}) self.pool.get('sale.order.line').button_confirm(cr, uid, [x.id for x in o.order_line]) self.confirm_send_note(cr, uid, ids, context) - return True + return True + + def manual_invoice(self, cr, uid, ids, context=None): + """ create invoices for the given sale orders (ids), and open the form + view of one of the newly created invoices + """ + mod_obj = self.pool.get('ir.model.data') + wf_service = netsvc.LocalService("workflow") + + # create invoices through the sale orders' workflow + inv_ids0 = set(inv.id for sale in self.browse(cr, uid, ids, context) for inv in sale.invoice_ids) + for id in ids: + wf_service.trg_validate(uid, 'sale.order', id, 'manual_invoice', cr) + inv_ids1 = set(inv.id for sale in self.browse(cr, uid, ids, context) for inv in sale.invoice_ids) + # determine newly created invoices + new_inv_ids = list(inv_ids1 - inv_ids0) + + res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_form') + res_id = res and res[1] or False, + + return { + 'name': _('Customer Invoices'), + 'view_type': 'form', + 'view_mode': 'form', + 'view_id': [res_id], + 'res_model': 'account.invoice', + 'context': "{'type':'out_invoice'}", + 'type': 'ir.actions.act_window', + 'nodestroy': True, + 'target': 'current', + 'res_id': new_inv_ids and new_inv_ids[0] or False, + } + + def action_invoice_create(self, cr, uid, ids, grouped=False, states=['confirmed', 'done', 'exception'], date_inv = False, context=None): res = False diff --git a/addons/sale_stock/sale_stock_workflow.xml b/addons/sale_stock/sale_stock_workflow.xml index 5177ab37720..7b757501e48 100644 --- a/addons/sale_stock/sale_stock_workflow.xml +++ b/addons/sale_stock/sale_stock_workflow.xml @@ -53,10 +53,6 @@ - - - -