(self, cr, uid, ids, context=None)
return {'type': 'ir.actions.act_window_close'}
To make invoices.

             @param self: The object pointer.
             @param cr: A database cursor
             @param uid: ID of the user currently logged in
             @param ids: the ID or list of IDs
             @param context: A standard dictionary

             @return: A dictionary which of fields with values.
To make invoices.
To make invoices .
def make_invoices(self, cr, uid, ids, context=None):
        """
             To make invoices.

             @param self: The object pointer.
             @param cr: A database cursor
             @param uid: ID of the user currently logged in
             @param ids: the ID or list of IDs
             @param context: A standard dictionary

             @return: A dictionary which of fields with values.

        """
        if context is None: context = {}
        res = False
        invoices = {}

    #TODO: merge with sale.py/make_invoice
        def make_invoice(order, lines):
            """
                 To make invoices.

                 @param order:
                 @param lines:

                 @return:

            """
            a = order.partner_id.property_account_receivable.id
            if order.partner_id and order.partner_id.property_payment_term.id:
                pay_term = order.partner_id.property_payment_term.id
            else:
                pay_term = False
            inv = {
                'name': order.client_order_ref or '',
                'origin': order.name,
                'type': 'out_invoice',
                'reference': "P%dSO%d" % (order.partner_id.id, order.id),
                'account_id': a,
                'partner_id': order.partner_invoice_id.id,
                'invoice_line': [(6, 0, lines)],
                'currency_id' : order.pricelist_id.currency_id.id,
                'comment': order.note,
                'payment_term': pay_term,
                'fiscal_position': order.fiscal_position.id or order.partner_id.property_account_position.id,
                'user_id': order.user_id and order.user_id.id or False,
                'company_id': order.company_id and order.company_id.id or False,
                'date_invoice': fields.date.today(),
            }
            inv_id = self.pool.get('account.invoice').create(cr, uid, inv)
            return inv_id

        sales_order_line_obj = self.pool.get('sale.order.line')
        sales_order_obj = self.pool.get('sale.order')
        for line in sales_order_line_obj.browse(cr, uid, context.get('active_ids', []), context=context):
            if (not line.invoiced) and (line.state not in ('draft', 'cancel')):
                if not line.order_id in invoices:
                    invoices[line.order_id] = []
                line_id = sales_order_line_obj.invoice_line_create(cr, uid, [line.id])
                for lid in line_id:
                    invoices[line.order_id].append(lid)
        for order, il in invoices.items():
            res = make_invoice(order, il)
            cr.execute('INSERT INTO sale_order_invoice_rel \
                    (order_id,invoice_id) values (%s,%s)', (order.id, res))
            sales_order_obj.invalidate_cache(cr, uid, ['invoice_ids'], [order.id], context=context)
            flag = True
            sales_order_obj.message_post(cr, uid, [order.id], body=_("Invoice created"), context=context)
            data_sale = sales_order_obj.browse(cr, uid, order.id, context=context)
            for line in data_sale.order_line:
                if not line.invoiced:
                    flag = False
                    break
            if flag:
                workflow.trg_validate(uid, 'sale.order', order.id, 'manual_invoice', cr)

        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 make_invoices ( self , cr , uid , ids , context = None ) : if context is None : context = { } res = False invoices = { } #TODO: merge with sale.py/make_invoice def make_invoice ( order , lines ) : """
                 To make invoices.

                 @param order:
                 @param lines:

                 @return:

            """ a = order . partner_id . property_account_receivable . id if order . partner_id and order . partner_id . property_payment_term . id : pay_term = order . partner_id . property_payment_term . id else : pay_term = False inv = { 'name' : order . client_order_ref or '' , 'origin' : order . name , 'type' : 'out_invoice' , 'reference' : "P%dSO%d" % ( order . partner_id . id , order . id ) , 'account_id' : a , 'partner_id' : order . partner_invoice_id . id , 'invoice_line' : [ ( 6 , 0 , lines ) ] , 'currency_id' : order . pricelist_id . currency_id . id , 'comment' : order . note , 'payment_term' : pay_term , 'fiscal_position' : order . fiscal_position . id or order . partner_id . property_account_position . id , 'user_id' : order . user_id and order . user_id . id or False , 'company_id' : order . company_id and order . company_id . id or False , 'date_invoice' : fields . date . today ( ) , } inv_id = self . pool . get ( 'account.invoice' ) . create ( cr , uid , inv ) return inv_id sales_order_line_obj = self . pool . get ( 'sale.order.line' ) sales_order_obj = self . pool . get ( 'sale.order' ) for line in sales_order_line_obj . browse ( cr , uid , context . get ( 'active_ids' , [ ] ) , context = context ) : if ( not line . invoiced ) and ( line . state not in ( 'draft' , 'cancel' ) ) : if not line . order_id in invoices : invoices [ line . order_id ] = [ ] line_id = sales_order_line_obj . invoice_line_create ( cr , uid , [ line . id ] ) for lid in line_id : invoices [ line . order_id ] . append ( lid ) for order , il in invoices . items ( ) : res = make_invoice ( order , il ) cr . execute ( 'INSERT INTO sale_order_invoice_rel \
                    (order_id,invoice_id) values (%s,%s)' , ( order . id , res ) ) sales_order_obj . invalidate_cache ( cr , uid , [ 'invoice_ids' ] , [ order . id ] , context = context ) flag = True sales_order_obj . message_post ( cr , uid , [ order . id ] , body = _ ( "Invoice created" ) , context = context ) data_sale = sales_order_obj . browse ( cr , uid , order . id , context = context ) for line in data_sale . order_line : if not line . invoiced : flag = False break if flag : workflow . trg_validate ( uid , 'sale.order' , order . id , 'manual_invoice' , cr ) 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' }