'Confirm the vouchers given in ids and create the journal entries for each of them'

@api.multi
def action_move_line_create(self):

    for voucher in self:
        local_context = dict(self._context, force_company=voucher.journal_id.company_id.id)
        if voucher.move_id:
            continue
        company_currency = voucher.journal_id.company_id.currency_id.id
        current_currency = (voucher.currency_id.id or company_currency)
        ctx = local_context.copy()
        ctx['date'] = voucher.account_date
        ctx['check_move_validity'] = False
        move = self.env['account.move'].create(voucher.account_move_get())
        move_line = self.env['account.move.line'].with_context(ctx).create(voucher.with_context(ctx).first_move_line_get(move.id, company_currency, current_currency))
        line_total = (move_line.debit - move_line.credit)
        if (voucher.voucher_type == 'sale'):
            line_total = (line_total - voucher._convert_amount(voucher.tax_amount))
        elif (voucher.voucher_type == 'purchase'):
            line_total = (line_total + voucher._convert_amount(voucher.tax_amount))
        line_total = voucher.with_context(ctx).voucher_move_line_create(line_total, move.id, company_currency, current_currency)
        if (voucher.tax_correction != 0.0):
            tax_move_line = self.env['account.move.line'].search([('move_id', '=', move.id), ('tax_line_id', '!=', False)], limit=1)
            if len(tax_move_line):
                tax_move_line.write({'debit': ((tax_move_line.debit + voucher.tax_correction) if (tax_move_line.debit > 0) else 0), 'credit': ((tax_move_line.credit + voucher.tax_correction) if (tax_move_line.credit > 0) else 0)})
        voucher.write({'move_id': move.id, 'state': 'posted', 'number': move.name})
        move.post()
    return True
